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 |
1A 怒贴代码#include<iostream> using namespace std; char s[10]; int n; int h; int dotpos; int r[155];//the result void multi(int r[],int a) { for(int i=0;i<=h;i++) { r[i]*=a; } for(int i=0;i<h;i++) { if(r[i]>9) { r[i+1]+=r[i]/10; } r[i]%=10; } int temp=r[h]; while(temp) { r[h++]=temp%10; temp/=10; } h--; } int main() { while(cin>>s>>n) { int num=0; h=0; for(int i=0;i<6;i++) { if(s[i]=='.') { dotpos=(5-i)*n-1; } else { num=num*10+s[i]-'0'; } } if(num==0) { cout<<0<<endl; continue; } memset(r,0,sizeof(r)); r[0]=1; for(int i=0;i<n;i++) multi(r,num); int trail; for(int i=0;i<=h;i++) if(r[i]) { trail=i; break; } if(dotpos>h) h=dotpos; int i; for(i=h;i>dotpos;i--) cout<<r[i]; if(dotpos>trail) cout<<"."; for(;i>=trail;i--) cout<<r[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