|
|
вернуться в форумWhy i don't get AC ? Can somebody help me with my solution - i don't know where is my mistake? As you can see i always get WA on test 8. #include<iostream> #include<string> using namespace std; string s; char c='0'; int base,st; int f(int b) { long long sol=0; for(int i=0;i<s.size();i++) if(s[i]>='0' && s[i]<='9') sol=(sol*b+int(s[i]-'0'))%(b-1); else if(s[i]>='A' && s[i]<='Z') sol=(sol*b+int(c-'A')+10)%(b-1); if(sol==0) return 1; else return 0; } int main() { while(c!='\n') {scanf("%c",&c); if((c>='0' && c<='9' ) || (c>='A' && c<='Z'))s+=c;} c='0'; for(int i=0;i<s.size();i++) { if(int(c)<int(s[i])) c=s[i]; } if(c>='0' && c<='9') st=int(c-'0'); else if(c>='A' && c<='Z') st=int(c-'A')+10; if(st==0) {printf("2\n"); return 0;} for(int i=st+1;i<=36;i++) if(f(i)==1) { printf("%d\n",i); return 0; } printf("No solution.\n"); return 0; } |
|
|