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. GTK+重拾--07 GTK+中的事件

    (一):写在前面 在这一个小节中,我们主要是学习GTK+2.0中最重要的部分.就是信号和事件.GTK+函数工具库是基于"事件"系统的.全部的GUI应用都是基于"事件&qu ...

  2. Js格式化json字符串

    var formatJson = function(json, options) { var reg = null, formatted = '', pad = 0, PADDING = ' '; / ...

  3. android 中使用svg

    http://www.see-source.com/blog/300000038/1189.html http://www.jianshu.com/p/30dfa5920658#

  4. QMessageBox简单使用

    首先要调用 #include <QMessageBox> 然后 QMessageBox msgBox; msgBox.setWindowTitle("错误"); msg ...

  5. linux多个分区合并为一个分区

    备份# rsync -avP -e ssh /data xxx卸载# umount /data /data?设置分区类型为8e# fdisk /dev/sdb 创建PV# pvcreate /dev/ ...

  6. Java多线程系列 JUC锁06 Condition条件

    Condition介绍 Condition中提供了一组类似于Object中的监视器方法.与Lock配合可以完成等待通知模式. Lock lock = new ReentrantLock(); Cond ...

  7. [原创]java WEB学习笔记12:一个简单的serlet连接数据库实验

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

  8. 【leetcode刷题笔记】Unique Binary Search Trees

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  9. static{}块的作用

    本文转载自: https://www.cnblogs.com/caolaoshi/p/7824748.html static{}块,会且仅会在类被加载时执行一次,多用于定义静态变量或执行静态方法. 什 ...

  10. 高通8X16电池BMS算法(一)【转】

    本文转载自:http://www.voidcn.com/blog/yanleizhouqing/article/p-6037399.html 最近一直在搞电源管理相关内容,之前是8610的bms,现在 ...