Exponentiation
Time Limit: 500MS   Memory Limit: 10000K
Total Submissions: 158025   Accepted: 38470

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
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN=;
struct BigInt{
int e[MAXN],len,pp;
BigInt()
{
memset(e,,sizeof(e));
len=;
pp=;
}
void set(const char s[])
{
int l=strlen(s);
for(int i=;i<l;i++)
{
if(s[i]=='.')
{
pp=l-i-;
continue;
}
e[len++]=s[i]-'';
}
for(int i=;i<len/;i++)
{
int t=e[i];
e[i]=e[len-i-];
e[len-i-]=t;
}
while(len>&&e[len-]==) len--;
}
BigInt operator*(const BigInt &b)
{
BigInt ret;
for(int i=;i<len;i++)
{
int up=;
for(int j=;j<b.len;j++)
{
int z=e[i]*b.e[j]+up+ret.e[i+j];
ret.e[i+j]=z%;
up=z/;
}
if(up!=)
{
ret.e[i+b.len]=up;
}
}
ret.len=len+b.len;
ret.pp=pp+b.pp;
while(ret.len>&&ret.e[ret.len-]==) ret.len--;
return ret;
}
void print()
{
int limit=;
while(e[limit]==&&limit<pp) limit++;//去后导0
if(pp>=len)
{
printf(".");
for(int i=pp;i>len;i--)
{
printf("");
}
for(int i=len-;i>=limit;i--)
{
printf("%d",e[i]);
}
printf("\n");
}
else
{
for(int i=len-;i>=pp;i--)
{
printf("%d",e[i]);
}
if(limit<pp)
{
printf(".");
for(int i=pp-;i>=limit;i--)
{
printf("%d",e[i]);
}
}
printf("\n");
}
}
};
char buf[];
int n;
int main()
{
while(scanf("%s%d",buf,&n)!=EOF)
{
BigInt t;
t.set(buf);
BigInt res;
res.set("1.0");
for(int i=;i<n;i++)
{
res=res*t;
}
res.print();
}
return ;
}

POJ1001(C++处理大数)的更多相关文章

  1. poj1001 Exponentiation【java大数】

    Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 183034   Accepted: 44062 ...

  2. poj1001 Exponentiation 大数的幂

    Description Problems involving the computation of exact values of very large magnitude and precision ...

  3. BZOJ 3110: [Zjoi2013]K大数查询 [树套树]

    3110: [Zjoi2013]K大数查询 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 6050  Solved: 2007[Submit][Sta ...

  4. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  5. c语言经典算法——查找一个整数数组中第二大数

    题目: 实现一个函数,查找一个整数数组中第二大数. 算法思想: 设置两个变量max1和max2,用来保存最大数和第二大数,然后将数组剩余的数依次与这两个数比较,如果这个数a比max1大,则先将max1 ...

  6. 杨氏矩阵:查找x是否在矩阵中,第K大数

    参考:http://xudacheng06.blog.163.com/blog/static/4894143320127891610158/ 杨氏矩阵(Young Tableau)是一个很奇妙的数据结 ...

  7. 蓝桥杯算法提高 P1001(大数乘法)

      算法提高 P1001   时间限制:1.0s   内存限制:256.0MB   当两个比较大的整数相乘时,可能会出现数据溢出的情形.为避免溢出,可以采用字符串的方法来实现两个大数之间的乘法. 具体 ...

  8. 51nod 1005 大数加法

    #include<iostream> #include<string> using namespace std; #define MAXN 10001 },b[MAXN]={} ...

  9. PHP大数(浮点数)取余

    一般我们进行取余运算第一个想到的就是用百分号%,但当除数是个很大的数值,超出了int范围时,这样取余就不准确了. php大数(浮点数)取余函数 /** * php大数取余 * * @param int ...

随机推荐

  1. Frobenius inner product

    https://en.wikipedia.org/wiki/Frobenius_inner_product Frobenius norm

  2. 【译】常见 Java 异常解释(恶搞版)

    常见 Java 异常解释:(译者注:非技术角度分析.阅读有风险,理解需谨慎o(╯□╰)o) java.lang ArithmeticException 你正在试图使用电脑解决一个自己解决不了的数学问题 ...

  3. linux -unrar解压缩

    解压缩命令unrar的使用: $unrar --help 用法:    unrar <command>-<switch 1> -<switchN> <arch ...

  4. 【python】将excel转成json

    excel格式如下: 转换后如下 {"BD": 1375.0, "BE": 829.0, "BF": 3.0, "BG" ...

  5. composer 更新国内镜像地址

    composer config -g repo.packagist composer https://packagist.phpcomposer.com​

  6. 让win10登陆时不再要求手动输入用户名

    如果windows每次登陆都要求手动输入用户名,可以用如下的方法避免: Windows10专业版.企业版和教育版用户 在运行或Cortana搜索栏输入secpol.msc后,按回车键进入"本 ...

  7. ansible普通用户su切换问题

    在现网应用中,安全加固后的主机是不允许直接以root用户登陆的,而很多命令又需要root用户来执行,在不改造现网的情况下.希望通过一个普通用户先登陆,再su切到root执行.而且每台主机的普通用户和r ...

  8. A股牛蹄板块轮动迹象

    2018年10月熊市末期牛市初期 1.券商 2.中小银行 3.稀土永磁 4.铁路基建 5.人工智能 6.电器仪表 7.保险 8.非进金融.供热供气

  9. scala基本学习

    def addOne(f: Int => Int, arg: Int) = f(arg) + 1,意思是 addOne要两个参数一个是:传一个整数的参数且返回一个整形的方法的参数,第二个参数就是 ...

  10. fffmpeg 提取pcm

    ffmpeg -i input.aac -codec:a pcm_f32le -ar 48000 -ac 2 -f f32le output.pcm