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 |
看似很水,不过却做了很长时间.../* Problem: 1001 User: iscubus Memory: 400K Time: 0MS Language: GCC Result: Accepted */ # include <stdio.h> # include <string.h> typedef struct Num { int n[1000]; int l,point; } num; num a,b,c; char s[20],s1[20]; int time; void cal() { int i,j; memset(c.n,0,sizeof(c.n)); for(i=1;i<=a.l;i++) for(j=1;j<=b.l;j++) { c.n[i+j-1]+=a.n[i]*b.n[j]; } c.l=a.l+b.l; for(i=1;i<=c.l;i++) { c.n[i+1]+=c.n[i]/10; c.n[i]%=10; } c.point=a.point+b.point; if(c.point<c.l&&c.n[c.l]==0) c.l--; a=c; } int main() { int i,j,l,l1,k,x,p,flag,f1; //freopen("in","r",stdin); while(scanf("%s%d",s,&time)!=EOF) { if(time==0) { printf("1\n"); continue; } l=strlen(s);j=1; flag=1;f1=0; for(i=0;i<l;i++) if(s[i]!='0'&&s[i]!='.') { flag=0; }else if(s[i]=='.') f1=1; if(flag) { printf("0\n"); continue; } flag=1;a.point=-2; i=0;j=l-1; while(s[i]=='0') i++; if(f1) while(s[j]=='0') j--; if(s[i]=='.') { x=1; for(k=j;k>i;k--) { a.n[x]=s[k]-'0'; x++; } a.point=x-1; a.l=j-i; }else if(s[j]=='.') { x=1; for(k=j-1;k>=i;k--) { a.n[x]=s[k]-'0'; x++; } a.point=-1; a.l=j-i; }else { x=1; for(k=j;k>=i;k--) { if(s[k]=='.') { a.point=x-1; }else { a.n[x]=s[k]-'0'; x++; } } if(a.point==-2) a.l=j-i+1; else a.l=j-i; } b=a; time--; while(time--) cal(); for(i=a.l;i>0;i--) { if(i==a.point) putchar('.'); printf("%d",a.n[i]); } putchar('\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