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> using namespace std; int main(void) { int i,m=9,k; unsigned __int64 b,q,n; __int64 a[30]; a[0] = 9; a[1] = 9; for(i=2; i<30; i++) { a[i] = a[i-2]*10; } while(scanf("%I64d",&n)&&n) { i=0; while(1) { if(n<a[i]) { b = n + a[i]/9-1; break; } if(n==a[i]) { b = 0; for(k=0;k<=i;k++) { b += a[k]; } if(!(i%2)) { b = a[k] + (b-a[k])/2; } else { if(i>0) b = a[k] + (b-2*a[k])/2; } break; } if(n>a[i]) { n = n-a[i]; i++; } } q = b; fprintf(stdout,"%I64d",q); if(i%2) { fprintf(stdout,"%I64d",b%10); b = b/10; } else { b = b/10; } while(b!=0) { fprintf(stdout,"%I64d",b%10); b = b/10; } 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