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 |
这题好阴,9,3,7 ID是从后往前开始乘的!白WA一次Memory: 144K Time: 110MS Language: C++ Result: Accepted •Source Code #include<iostream> #include<string> using namespace std; int prime[3]={9,3,7}; int main(){ char s[10]={'\0'}; int n,count=0,sum,j,flag,index; scanf("%d",&n); while(count!=n){ sum=j=0; scanf("%s",s); for(int i=strlen(s)-1;i>=0;i--) { if(s[i]=='?') { index=i; flag=j; } else sum+=(s[i]-48)*prime[j]; if(j==2) j=0; else j++; } for(int i=0;i<10;i++) if((sum+prime[flag]*i)%10==0) { s[index]=static_cast<char>(i+48); break; } printf("Scenario #%d:\n%s\n\n",++count,s); memset(s,'\0',sizeof(s)); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator