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 |
C式C++ 较短代码#include <stdio.h> unsigned long long N=1000000000000000LL,in, d[25][2]={{665459056928801LL,12157}},d2[40]={1}; int main(){ int t,f; for(int i=1;i<25;++i){ d[i][0]=(d[i-1][0]*3)%N; d[i][1]=d[i-1][0]*3/N+d[i-1][1]*3; } for(int i=1;i<40;++i){ d2[i]=d2[i-1]*3; } while(1){ scanf("%llu",&in); if(in==0) break; if(in==1) {printf("{ }\n");continue;} printf("{ "); in-=1; t=f=0; while(in!=0){ if(in&1) { if(!f) f=1; else printf(", "); if(t<40) printf("%llu",d2[t]); else printf("%llu%015llu",d[t-40][1],d[t-40][0]); } in>>=1; t++; } printf(" }\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator