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 \le 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 Rn. Leading zeros and insignificant trailing zeros should be suppressed in the output.

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

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char str[1000],a[1000],a1[1000];
int c;
int n,i,j,k,t,x,num,t1,t2,y,y1,y2;
while(cin>>str>>n)
{ x=0;num=0;
t=strlen(str);
for(i=0;i<t;i++)
{
if(str[i]=='.')
{
num=t-1-i;
i++;
}
a[x]=str[i];
a1[x++]=str[i];
}
a[x]='\0';
a1[x]='\0';
num*=n;
int x1=x;
for(i=0;i<n-1;i++)
{
int sum[1000]={0};
t1=999;t2=999;
for(j=x-1;j>=0;j--)
{
for(k=x1-1;k>=0;k--)
sum[t1--]+=((a[j]-'0')*(a1[k]-'0'));
t2--;
t1=t2;
}
c=0;
for(y=999;y>=0;y--)
{
sum[y]+=c;
c=0;
if(sum[y]>9)
{
c=sum[y]/10;
sum[y]=sum[y]%10;
}
}
for(y1=0;y1<1000;y1++)
{
if(sum[y1]!=0)
break;
}
x1=0;
for(y2=y1;y2<1000;y2++)
a1[x1++]=sum[y2]+'0';
a1[x1]='\0';
}
if(num==0)
cout<<a1<<endl;
else
{
t=strlen(a1);
if(a1[t-1]=='0')//若(2.0, 2)则输出4而不是4.00,多余的零去掉
{
for(i=t-1;i>=0;i--)
{
if(a1[i]!='0')
break;
num--;//小数点的位数
}
t=i+1;
}
for(i=0;i<t-num;i++)
cout<<a1[i];//输出小数点之前的
cout<<".";
while(num>t-i)//若整数部分为0,小数部分不够填补小数点后的位数0
{
cout<<"0";
num--;
}
for(j=i;j<t;j++)
cout<<a1[j];//输出小数点后的
cout<<endl;
}
}
return 0;
}

Exponentiation的更多相关文章

  1. 【PKU1001】Exponentiation(高精度乘法)

    Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 145642   Accepted: 35529 ...

  2. uva748 - Exponentiation

    import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class Exponenti ...

  3. [POJ] #1001# Exponentiation : 大数乘法

    一. 题目 Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 156373   Accepted: ...

  4. Poj 1001 / OpenJudge 2951 Exponentiation

    1.链接地址: http://poj.org/problem?id=1001 http://bailian.openjudge.cn/practice/2951 2.题目: Exponentiatio ...

  5. POJ 1001 Exponentiation 无限大数的指数乘法 题解

    POJ做的非常好,本题就是要求一个无限位大的指数乘法结果. 要求基础:无限大数位相乘 额外要求:处理特殊情况的能力 -- 关键是考这个能力了. 所以本题的用例特别重要,再聪明的人也会疏忽某些用例的. ...

  6. HDU Exponentiation 1063 Java大数题解

    Exponentiation Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  7. Problem F: Exponentiation

    Problem F: ExponentiationTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 4 Solved: 2[Submit][Status][W ...

  8. Exponentiation(java 大实数)

    http://acm.hdu.edu.cn/showproblem.php?pid=1063 Exponentiation Time Limit: 2000/500 MS (Java/Others)  ...

  9. ( 大数 startsWith substring) Exponentiation hdu1063

    Exponentiation Time Limit: 2000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  10. POJ 1001 Exponentiation(大数运算)

    POJ 1001 Exponentiation 时限:500 ms   内存限制:10000 K 提交材料共计: 179923   接受: 43369 描述:求得数R( 0.0 < R < ...

随机推荐

  1. 为什么需要Page Object?

    为什么需要Page Object? Page Object(PO)是界面自动化验收测试中的一个常见模式,要和@槽神刘叫兽探讨一下PO的必要性,顾写这篇小文表达一下我的观点. PO的主要价值体现在对界面 ...

  2. VS快捷方式小技巧

    VS2005代码编辑器的展开和折叠代码确实很方便和实用.以下是展开代码和折叠代码所用到的快捷键,很常用: Ctrl + M + O: 折叠所有方法 Ctrl + M + M: 折叠或者展开当前方法 C ...

  3. Win8.1重装win7或win10中途无法安装

    一.有的是usb识别不了,因为新的机器可能都是USB3.0的,安装盘是Usb2.0的. F12更改系统BIOS设置,我改了三个地方: 1.设置启动顺序为U盘启动 2.关闭了USB3.0 control ...

  4. DataTable去除重复行

    //抽取dt中的特定列"Region","Cur","Year"组合成新的dat DataTable dat = dt.DefaultVie ...

  5. ROS的文件系统

    这篇博客介绍一下ROS的文件系统的基本概念,用户可以直接在官方网站:http://wiki.ros.org/ROS/Tutorials/NavigatingTheFilesystem去查看官方手册. ...

  6. 列求key出现的频率

    1 cat mc.log | grep LOGIN_GET | awk '{print $9}' | sort | uniq -c

  7. WSDL规则解释(转)

    转自:http://www.blogjava.net/baoyaer/articles/116413.html WSDL文档可以分为两部分.顶部分由抽象定义组成,而底部分则由具体描述组成.抽象部分以独 ...

  8. Nginx +iis反向代理

    一:简介      Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所 ...

  9. MyEclipseアンロックの手順

    ↓ ↓ ↓ ↓ ↓ ↓

  10. 大数据技术 vs 数据库一体机[转]

    http://blog.sina.com.cn/s/blog_7ca5799101013dtb.html 目前,虽然大数据与数据库一体机都很火热,但相当一部分人却无法对深入了解这两者的本质区别.这里便 ...