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 |
请帮忙看看!没错,但提交时说是wrong answer!#include <iostream.h> #include <memory.h> void deal(int n,char a[7]) { int i,b[125],c[5],j,k,d[125],and=0,temp,jw=0,Temp,m=0,last=0; memset(b,0,sizeof(b)); memset(d,0,sizeof(d)); for(i=0,j=4;i<6;i++) { if(a[i]!='.') { c[j]=a[i]-48; j--; } else m=(5-i)*n; } for(i=1;i<=n;i++) { if(i==1) { for(j=0;j<5;j++) { b[j]=c[j]; } } else { for(j=0;j<5;j++) { if(j==0) memset(d,0,sizeof(d)); for(k=0;k<120;k++) { temp=and; Temp=jw; and=(c[j]*b[k]+and)/10; jw=(d[j+k]+jw+(c[j]*b[k]+temp)%10)/10; d[k+j]=(d[k+j]+Temp+(c[j]*b[k]+temp)%10)%10; } and=0; jw=0; } for(j=0;j<125;j++) { b[j]=d[j]; } } } for(k=0;k<=124;k++) if(d[k]!=0) { last=k;break; } for(k=124;k>=0;k--) { if(d[k]!=0) { break; } } if(k>=m-1) { for(j=k;j>=last;j--) { if(j==(m-1)) cout<<"."; cout<<d[j]; } } else { for(j=m-1;j>=last;j--) { if(j==(m-1)) cout<<"."; cout<<d[j]; } } cout<<endl; } void main() { int m,s=0; char b[7]="0"; while(cin) { for(s=0;s<6;s++) cin>>b[s]; cin>>m; deal(m,b); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator