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 |
同样的代码 long long WA __int64 AC__int64 #include "stdio.h" __int64 a[11]; void search(int x) { __int64 i,k,j,l; for(i=0;i<=9;i++) a[i]=0; k=1; while(x>=k) { k*=10; for(i=0;i<=9;i++) a[i]+=(x/k)*(k/10); a[0]-=k/10; j=x%(k/10); l=(x%k)/(k/10); for(i=0;i<l;i++) a[i]+=(k/10); a[l]+=j+1; } } int main() { __int64 m,tt,n,i,t[11]; while(scanf("%I64d%I64d",&m,&n)==2) { if(m==0&&n==0) break; if(m>n) { tt=n; n=m; m=tt; } search(n); for(i=0;i<=9;i++) t[i]=a[i]; search(m-1); for(i=0;i<=9;i++) t[i]-=a[i]; for(i=0;i<=9;i++) { if(i!=0) printf(" "); printf("%I64d",t[i]); } printf("\n"); } return 0; } long long #include "stdio.h" long long a[11]; void search(int x) { long long i,k,j,l; for(i=0;i<=9;i++) a[i]=0; k=1; while(x>=k) { k*=10; for(i=0;i<=9;i++) a[i]+=(x/k)*(k/10); a[0]-=k/10; j=x%(k/10); l=(x%k)/(k/10); for(i=0;i<l;i++) a[i]+=(k/10); a[l]+=j+1; } } int main() { long long m,tt,n,i,t[11]; while(scanf("%lld%lld",&m,&n)==2) { if(m==0&&n==0) break; if(m>n) { tt=n; n=m; m=tt; } search(n); for(i=0;i<=9;i++) t[i]=a[i]; search(m-1); for(i=0;i<=9;i++) t[i]-=a[i]; for(i=0;i<=9;i++) { if(i!=0) printf(" "); printf("%lld",t[i]); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator