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 |
Re:超时,大牛帮帮忙,简化一下啊In Reply To:超时,大牛帮帮忙,简化一下啊 Posted by:10074182 at 2009-08-04 15:36:38 > #include <stdio.h> > #include<stdlib.h> > #include<string.h> > int main() > { > int n,i,j,len,k,h,fac,need,sum; > char id[8]; > scanf("%d",&n); > for(i=1;i<=n;i++) > { > scanf("%s",id); > len=strlen(id); > sum=0; > for(j=len-1;j>=0;j--) > { > if(id[j]!='?') > { > if((len-j)%3==1) > sum+=(id[j]-'0')*9; > else if((len-j)%3==2) > sum+=(id[j]-'0')*3; > else > sum+=(id[j]-'0')*7; > } > else > k=j; > } > need=10-sum%10; \\要加数的个位数字 > printf("Scenario #%d:\n",i); > if((len-k)%3==1) > fac=9; > else if((len-k)%3==2) > fac=3; > else > fac=7; > for(h=1;h<=9;h++) > if((h*fac)%10==need) > break; > id[k]=h+'0'; > printf("%s\n\n",id); > } > system("pause"); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator