Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位大哥帮看小弟看一下为什么总WAIn Reply To:Please give me some sample tests. Thanks! Posted by:yogafrank at 2007-09-15 19:27:57 #include<iostream> #include<string> using namespace std; int main() { string str; while(getline(cin,str)) { if(str=="0") { cout<<2<<endl; continue; } int i,sum=0,max=0; for(i=0;i<str.length();i++) { if(str[i]>='0'&&str[i]<='9') { if(str[i]-'0'>max) max=str[i]-'0'; sum+=str[i]-'0'; } else if(str[i]>='A'&&str[i]<='Z') { if(str[i]-55>max) max=str[i]-55; sum+=str[i]-55; } else if(str[i]>='a'&&str[i]<='z') { if(str[i]-61>max) max=str[i]-61; sum+=str[i]-61; } } for(i=max;i<=61;i++) { if(sum%i==0) { cout<<(i+1)<<endl; break; } } if(i>62) cout<<"such number is impossible!"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator