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 |
第一次发现PE可以是这么郁闷的...1 578 .0017301038062283737024221453287197231833910034602 07612456747404844290657439446366782006920415224913 49480968858131487889273356401384083044982698961937 71626297577854671280276816608996539792387543252595 15570934256055363321799307958477508650519031141868 512110726643598615916955 The last 272 digits repeat forever. 这样没错吧... #include<stdio.h> #define MAX 1001 int list[MAX][2],tail; inline void initList(){ int i; for(i=0;i<MAX;i++)list[i][0]=-1; } inline int in(int k){ if(list[k][0]!=-1){ return k; }else{ return -1; } } inline void add(int k,int i){ if(list[k][0]!=-1)return; list[k][0]=k; list[k][1]=i; } int remain; inline void print(int i){ char bu[999]; int l,j; l=sprintf(bu,"%d",i); for(j=0;j<l;j++){ printf("%c",bu[j]); remain--; if(!remain){ printf("\n"); remain=50; } } } inline void print(char c[]){ int i; for(i=0;c[i];i++){ printf("%c",c[i]); remain--; if(!remain){ printf("\n"); remain=50; } } } int main(){ int a,b,i,x; while(1){ scanf("%d%d",&a,&b); if(!a && !b)break; initList(); remain=49; printf("."); if(!a)printf("0"); x=1; i=0; while(a){ if(!x){ if(in(a)!=-1)break; }else{ x=0; } add(a,i++); a*=10; if(a<b){ print("0"); }else{ print(a/b); a%=b; } } if(!a){ printf("\nThis expansion terminates.\n"); }else{ printf("\nThe last %d digits repeat forever.\n",i-list[in(a)][1]); } } return 0; } 希望高手可以指点一下,谢谢 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator