ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1104. Don’t Ask Woman about Her Age

WA#4
Posted by evil 11 Sep 2016 17:06
The following is my program,i want to know why it always be "wrong answer".


#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    int i,k,m,n;
    double s;
    bool f,t;
    char a[100000];
    while(scanf("%s",a)!=EOF)
    {
        int d=strlen(a);
        char max=a[0];
        for(i=1;i<d;i++)
        {
            if(a[i]>max)
                max=a[i];
        }
        if(max>='A'&&max<='Z')
            m=max-65+10;
        else m=max-'0';
        for(k=2;k<=36;k++)
        {
            s=0;
            f=false;
            t=true;
            if(m>=k)
                continue;
            for(i=0;i<d;i++)
            {
                if(a[i]>='A'&&a[i]<='Z')
                    n=a[i]-65+10;
                else
                    n=(int)a[i]-48;
                if(n==0&&t)
                    continue;
                else t=false;
                s=s+n*pow(k,d-i-1);
            }

            if((int)s%(k-1)==0)
            {
                f=true;
                break;
            }
        }
        if(f)
            printf("%d\n",k);
        else
            printf("No solution.\n");
    }
    return 0;
}