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. JavaScript-Confirm用法

    function checkMobileBind() {    if(confirm('您尚未绑定手机,是否前往绑定?'))    {        window.location='http://m ...

  2. win7 32位下载安装redis并安装php_redis扩展

    redis打包文件下载地址:http://files.cnblogs.com/files/cuiwenyuan/Redis-3.2.100-Windows-32.zip php_redis.dll下载 ...

  3. python+NLTK 自然语言学习处理五:词典资源

    前面介绍了很多NLTK中携带的词典资源,这些词典资源对于我们处理文本是有大的作用的,比如实现这样一个功能,寻找由egivronl几个字母组成的单词.且组成的单词每个字母的次数不得超过egivronl中 ...

  4. 33_为应用添加多个Activity与参数传递

    1\ 2\ 3\ 4\ 2 3

  5. eclipse---个人设置

    window---- preferences -----修改背景颜色 -----修改字体 ----修改窗口主题 ----设置编码 -----设置编译环境 ----设置web项目JDK编译的版本 --- ...

  6. HDU - 5703 Desert 【找规律】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5703 题意 给出一杯容量为N的水 每次至少喝1个单位 有多少种不同的方式喝完 比如 给出3 就有4种方 ...

  7. windows与VMware ubuntu虚拟机实现文件共享

    本文基本摘自:无限挑战者的博客 本人用的系统是win10系统,应该区别不大,实现的是win10系统和VMWare虚拟机Ubantu系统之间的文件共享.到网上找了很多的方法各种各样的方式,由于对Linu ...

  8. [原创]java WEB学习笔记38:EL 中的 11个 隐含对象 详解

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  9. centos7下Zookeeper+sheepdog集群搭建

    zookeeper 安装命令 yum install zookeeper -y            (版本:zookeeper.x86_64      3.4.6-1) yum install zo ...

  10. PostgreSQL 与 MySQL 相比,优势何在?【转】

    最近看到PostgreSQL话题比较多,就搜索了一下它与mysql的对比作者:知了链接:http://www.zhihu.com/question/20010554/answer/74037965来源 ...