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> #include<memory.h> using namespace std; long length(long a) { long i=1; while(a/10!=0) { i++; a=a/10; } return i; } long main() { float r; long n,t; long dot=0,c=0; long s[500]={0}; long i,j,k; while(cin>>r>>n) { for(i=0;i<500;i++) s[i]=0; if(n==0) { cout<<"1"<<endl; continue; } if(r*10000<1) { cout<<"0"<<endl; continue; } if(length(long(r))==1) { dot=4; r*=10000; } else if(length(long(r))==2) { dot=3; r*=1000; } dot*=n; t=long(r); for(i=0;t!=0;i++) { s[i]=t%10; t=t/10; } j=i; for(k=1;k<n;k++) { for(i=0;i<j;i++) { s[i]=s[i]*r+c; c=s[i]/10; s[i]=s[i]%10; } while(c!=0) { s[i++]=c%10;//// c=c/10; } j=i; } long z=0; for(k=0;k<dot;k++) { if(s[k]==0) z++; else break; } if(i<=dot) { cout<<"."; for(i=dot-1;i>=z;i--) cout<<s[i]; cout<<endl; } else { for(i=i-1;i>=z;i--) { cout<<s[i]; if(i==dot&&z!=dot) cout<<"."; } 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