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 |
水过#include<iostream> #include<cstring> using namespace std; int main() { int n; cin>>n; for(int i=0;i<n;i++) { char record[9]={0}; cin>>record; int len=strlen(record); int sum=0,sign; for(int j=len-1;j>=0;j--) { if(record[j]!='?' && (j==len-1 || j==len-4 || j==len-7)) { sum+=(record[j]-'0')*9; } else if(record[j]!='?' && (j==len-2 || j==len-5 || j==len-8)) { sum+=(record[j]-'0')*3; } else if(record[j]!='?' && (j==len-3 || j==len-6 || j==len-9)) { sum+=(record[j]-'0')*7; } else sign=j; } for(int k=0;k<=9;k++) { int temp=sum; if(sign==len-1 || sign==len-4 || sign==len-7) temp+=k*9; else if(sign==len-2 || sign==len-5 || sign==len-8) temp+=k*3; else if(sign==len-3 || sign==len-6 || sign==len-9) temp+= k*7; if(temp%10==0) { record[sign]=k+'0'; break; } } cout<<"Scenario #"<<i+1<<":"<<endl; cout<<record<<endl; cout<<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