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 |
WA无数次的注意了0.1000 1 答案是 .1 小数点前面不要0,小数点要写成.xxxxx,而不是0.xxxxx #include <iostream> #include <algorithm> #include <utility> #include <cmath> #include <queue> #include <string> #include<iomanip> using namespace std; int main() { int i,j,k,l,z,m,n,a,b,x,y,s; char r[10]; while(cin>>r>>n){ int num[200]={0}; for(i=0;i<6&&r[i]!='.';i++)if(r[i]-'0')break; for(j=5;j>=0&&r[j]!='.';j--)if(r[j]-'0')break; for(k=0;k<6;k++)if(r[k]=='.')l=j-k; for(k=i,s=0;k<=j;k++){ if(r[k]=='.')continue; s=s*10+(r[k]-'0'); } if(s==0){cout<<0<<endl;continue;} num[0]=1; for(i=0;i<n;i++){ b=0; for(j=0;j<199;j++){ a=num[j]*s+b; num[j]=a%10; b=a/10; } } for(i=199;i>=0;i--){ if(l*n-1==i){cout<<'.'<<num[i--];break;} if(num[i])break; } for(;i>=0;i--){ if(l*n-1==i)cout<<'.'; cout<<num[i]; } 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