| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1445 人关注过本帖
标题:高精度
取消只看楼主 加入收藏
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
 问题点数:0 回复次数:5 
高精度

Time Limit:1000MS Memory Limit:65536K
Total Submit:0 Accepted:0

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.


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 12
0.4321 20
5.1234 15
6.7592 9
98.999 10
1.0100 12

Sample Output


548815620517731830194541.899025343415715973535967221869852721
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
43992025569.928573701266488041146654993318703707511666295476720493953024
29448126.764121021618164430206909037173276672
90429072743629540498.107596019456651774561044010001
1.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

Source

East Central North America 1988

搜索更多相关主题的帖子: 高精度 computation Limit exact magnitude 
2007-10-12 15:35
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 

会做的请帮忙解决一下
希望大家帮忙 确实不会做 会做的都做了啊

[此贴子已经被作者于2007-10-16 8:04:02编辑过]


前世五百次的回眸 才换来今生的擦肩而过
2007-10-13 13:53
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 
不好意思 真的希望能帮一下忙

前世五百次的回眸 才换来今生的擦肩而过
2007-10-15 22:49
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 
贴出来一下 谢谢

前世五百次的回眸 才换来今生的擦肩而过
2007-10-15 22:58
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
char a[150]={0};
int n;
while(scanf("%s%d",a,&n)!=EOF)
{ int b[150]={0},i,j,lend,num1,num2,num,sum=0,ten=1,suger;
lend=strlen(a)-1;
for(i=0;i<=lend;i++)
if(a[i]=='.')
break;
num1=lend-i;
for(j=i;j<lend;j++)
a[j]=a[j+1];
lend=lend-1;
for(j=lend;j>=i;j--)
{ if(a[j]!='0')
break;
}
num2=lend-j;
lend=j;
num=(int)fabs(num1-num2);
num=num*n;
for(i=0;i<=lend;i++)
b[i]=a[i]-48;
do
{ sum=sum+b[lend]*ten;
ten=ten*10;
lend--;
} while(lend>=0);
int temp,la,digit[1000];
la = 0,digit[0] = 1;
for(temp=1;temp<=n;temp++)
{
digit[0] = digit[0]*sum;
for(i=1;i<=la;i++)
{
digit[i] = digit[i]*sum;
digit[i] = digit[i] + digit[i-1]/10;
digit[i-1] = digit[i-1]%10;
}
while(digit[la]>=10)
{
la= la + 1;
digit[la] = digit[la-1] /10;
digit[la-1] = digit[la-1]%10;
}
}
if(b[0]==0)
{ printf(".");
for(i=num;i>la+1;i--)
printf("0");
for(i=la;i>=0;i--)
printf("%d",digit[i]);
}
else if(num!=0)
{ for(i=la;i>=num;i--)
printf("%d",digit[i]);
printf(".");
for(i=num-1;i>=0;i--)
printf("%d",digit[i]);
}
else if(num==0)
for(i=la;i>=0;i--)
printf("%d",digit[i]);
printf("\n");
}
return 0;
}
另外
对于整数
#include <iostream>
using namespace std;
int main()
{
int n,temp,la,i,digit[310],c;
while(cin>>c>>n)
{
la = 0,digit[0] = 1;
for(temp=1;temp<=n;temp++)
{
digit[0] = digit[0]*c;
for(i=1;i<=la;i++)
{
digit[i] = digit[i]*c;
digit[i] = digit[i] + digit[i-1]/10;
digit[i-1] = digit[i-1]%10;
}
while(digit[la]>=10)
{
la= la + 1;
digit[la] = digit[la-1] /10;
digit[la-1] = digit[la-1]%10;
}
}
for(i=la;i>=0;i--)
cout<<digit[i];
cout<<endl;
}
return 0;
}

前世五百次的回眸 才换来今生的擦肩而过
2007-10-26 18:30
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 

前世五百次的回眸 才换来今生的擦肩而过
2007-10-26 18:32
快速回复:高精度
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012214 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved