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

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

搜索更多相关主题的帖子: 小数 高精度 
2007-10-17 10:02
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 
各位大哥大姐 请指教

前世五百次的回眸 才换来今生的擦肩而过
2007-10-18 07: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;
}


前世五百次的回眸 才换来今生的擦肩而过
2007-10-24 20:23
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 
我的对了 题目要求只能输入小数 如整数输入10.0 才行 我的是把小数化为整数来做啊
谢了 各位

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

我的程序和你的题目不一样啊
听说您变成很厉害啊
指点一下我的提问啊
谢谢


前世五百次的回眸 才换来今生的擦肩而过
2007-10-26 19:07
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
收藏
得分:0 
我的题目是北大acm1001题
http://acm.pku.edu.cn/JudgeOnline/

前世五百次的回眸 才换来今生的擦肩而过
2007-10-26 19:08
快速回复:高精度求小数的幂次方 真的希望各位大哥能指点一下 谢谢
数据加载中...
 
   



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

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