POJ 1001 Exponentiation
来源:互联网 发布:app用户行为数据采集 编辑:程序博客网 时间:2024/05/16 17:25
Exponentiation
Time Limit: 500MS Memory Limit: 10000KTotal Submissions: 111039 Accepted: 26981
Description
Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems.
This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.
This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.
Input
The input will consist of a set of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 and 9.
Output
The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don't print the decimal point if the result is an integer.
Sample Input
95.123 120.4321 205.1234 156.7592 998.999 101.0100 12
Sample Output
548815620517731830194541.899025343415715973535967221869852721.0000000514855464107695612199451127676715483848176020072635120383542976301346240143992025569.92857370126648804114665499331870370751166629547672049395302429448126.76412102161816443020690903717327667290429072743629540498.1075960194566517745610440100011.126825030131969720661201
Hint
If you don't know how to determine wheather encounted the end of input:
s is a string and n is an integer
s is a string and n is an integer
C++while(cin>>s>>n){...}cwhile(scanf("%s%d",s,&n)==2) //to see if the scanf read in as many items as you want/*while(scanf(%s%d",s,&n)!=EOF) //this also work */{...}
Source
East Central North America 1988
#include<iostream>using namespace std;int x[10000];void mul(int x[],int y){for(int k=0;k<10000;k++) x[k]=x[k]*y; for(int k=0;k<10000;k++) { x[k+1]+=x[k]/10; x[k]=x[k]%10; }}int main(){int i,j,l,n,p,q,r,t; long m; char a[10]; while(cin>>a>>n){p=0,q=0,m=0; for(l=0;l<10000;l++)x[l]=0; x[0]=1; if(n==0) cout<<1<<endl; else{ for(i=5;i>=0;i--){if(a[i]!='.') p++; else break;}for(i=5,j=0;i>=0;i--){if(a[i]!='0') break; else j++;} p=p-j; p=p*n; q=6-j; for(i=0;i<q;i++) if(a[i]=='.') continue; else m=m*10+a[i]-'0'; for(q=0;q<n;q++) mul(x,m); for(q=9999;x[q]==0;q--) r=q; if(p>r) { t=p-r; for(r=r-1;r>=p;r--) cout<<x[r]; cout<<"."; while(t--) cout<<0; for(;r>=0;r--) cout<<x[r]; cout<<endl; } else { for(r=r-1;r>=p;r--) cout<<x[r]; if(r<0) goto end; cout<<"."; for(;r>=0;r--) cout<<x[r]; end:cout<<endl; } }}return 0;}
- POJ 1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001 Exponentiation
- POJ 1001 "Exponentiation"
- poj 1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001 exponentiation
- 【POJ】1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001Exponentiation
- 《POJ 1001》 Exponentiation
- POJ 1001 Exponentiation
- [POJ]1001 Exponentiation
- POJ-1001-Exponentiation
- [poj] 1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001 Exponentiation
- POJ-1001 Exponentiation 高精度
- 北京野趣水库烧烤好去处882
- uva 11624
- MyGUI3.2.0编译及运行Demo
- 基于jsp+java的团购网站毕业设计(优秀毕业论文)
- 图像匹配
- POJ 1001 Exponentiation
- Android 技巧:隐藏 System UI
- 图片渐出效果
- 《程序员密码学》之消息认证码算法
- HDU 1879 最小生成树 prim + kruskal
- 通过SQL语句设置或删除主键——CONSTRAINT用法
- 欧拉回路和哈密尔顿回路
- 图片显示文字效果
- SQLite剖析(9):动态内存分配