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<stdio.h>
#include<string.h> char *touzero(char *tmp)
{
if(*tmp=='0'&&*(tmp+1)!='\0')
{
tmp=tmp+1;
tmp=touzero(tmp);
}
return tmp;
} int weizero(char *tmp,int m)
{
if(*tmp=='0')
{
m++;
*tmp='\0';
tmp=tmp-1;
m=weizero(tmp,m);
}
return m;
} int main()
{
char s[7],d[150];
int e[150];
char *tmp;
int i,j,k,n,tmpint;
int m;
int c; while(~scanf(" %s %d",s,&n))
{
c=0;
k=m=-1;
memset(e,0,sizeof(e));
memset(d,0,sizeof(d));
s[6]='\0';
tmp=s+5;
for(i=0;i<sizeof(s);i++)
{
if(s[i]=='.')
{
m=i;
k=4-weizero(tmp,k)-i;
break;
}
}
if(m!=-1)
{
for(i=m;i<(sizeof(s)-1);i++)
{
s[i]=s[i+1];
}
s[i]='\0';
}
tmp=s;
tmp=touzero(tmp);
strcpy(s,tmp);
i=0;
while(s[i]!='\0')i++;
j=i-1;
do
{
i--;
e[j-i]=(int)s[i]-48;
}while(i>0);
sscanf(s,"%d",&tmpint);
for(i=0;i<n-1;i++)
{
for(j=0;j<149;j++)
{
e[j]=e[j]*tmpint;
}
for(j=0;j<149;j++)
{
e[j+1]=e[j+1]+e[j]/10;
e[j]=e[j]%10;
}
}
tmpint=0;
m=0;
for(i=0;i<150;i++)
{
if(e[i]!=0){m=1;break;}
}
if(n==0)
printf("1\n");
else if(m==0)
printf("0\n");
else
{
for(i=0;i<150;i++)//输出
{
if(tmpint==0&&e[149-i]==0&&150-i>k*n)
{
continue;
}
tmpint=1;
if(i==150-k*n)
{
printf(".");
}
printf("%d",e[149-i]);
}
printf("\n");
}
}
return 0;
}

  

北大poj-1001的更多相关文章

  1. 北大POJ题库使用指南

    原文地址:北大POJ题库使用指南 北大ACM题分类主流算法: 1.搜索 //回溯 2.DP(动态规划)//记忆化搜索 3.贪心 4.图论 //最短路径.最小生成树.网络流 5.数论 //组合数学(排列 ...

  2. POJ 1001 Exponentiation(大数运算)

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

  3. [POJ 1001] Exponentiation C++解题报告 JAVA解题报告

        Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 126980   Accepted: 30 ...

  4. poj 1001

    http://poj.org/problem?id=1001 这是一道高精度的运算,如果你之前有写过那种高精度的乘法的题目的话,做这个也还是比较简单的.. 思路:我是首先把小数点的位置确定下来,然后其 ...

  5. Poj 1001 / OpenJudge 2951 Exponentiation

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

  6. POJ 1001 解题报告 高精度大整数乘法模版

    题目是POJ1001 Exponentiation  虽然是小数的幂 最终还是转化为大整数的乘法 这道题要考虑的边界情况比较多 做这道题的时候,我分析了 网上的两个解题报告,发现都有错误,说明OJ对于 ...

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

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

  8. 北大OJ 1001题

    题目:输入一序列的正实数和幂次(正整数)对,然后打印结果(具体的比这个精细) 这道题是关于大数计算的(大数求幂),从开始建立思路,到写代码.调式到最后被AC以及最终的优化,总共用了差不多一天的时间.开 ...

  9. POJ 1001 Exponentiation(JAVA,BigDecimal->String)

    题目 计算实数a的n次方,具体输出格式看案例 import java.util.*; import java.math.*; public class Main { public static voi ...

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

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

随机推荐

  1. Windows日志查看工具合集

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://github.com/jiangxincode 知乎地址 ...

  2. 5.3.2 Eclipse集成开发环境的使用技巧

    Eclipse具有强大的编辑.调试.编译和打包功能,本节仅讲解Eclipse中最常用的功能. 1.将程序代码和注释字体变大 (1)启动Eclipse,选择“Windows”->“Preferen ...

  3. robotframework笔记23

    远程库接口 远程库接口提供了对在测试库 比机器人框架本身是在不同的机器上运行, 同时实现图书馆使用其他语言比 本机支持Python和Java. 为一个测试库用户远程 library看起来几乎一样的其他 ...

  4. [maven] pom.xml 文件详解

    参考资料: http://blog.csdn.net/uohzoaix/article/details/7035307 http://www.cnblogs.com/qq78292959/p/3711 ...

  5. kellogg项目总结

    1.题目的去随机值去重 (当时做的是每次点击取出一个随机数,并删除数组中位置,后来改成获取10个随机数组成的数组,二者略有差距,修改颇长时间) function getArr(num){ totalA ...

  6. ubuntu安装bower失败的解决方法

    1.安装nodejs 2.安装npm 3.安装bower 最开始使用 npm install bower -g / sudo npm install bower -g 安装bower后 命令行输入bo ...

  7. 读书笔记3 Socket

    Socket被称为网络插座.用于两个网络应用程序之间的通信. 通信地址:URI 通过协议,地址,端口号可以确定网络上的一个程序.地址和端口号组合称之为端点. 通常会有发信人通信地址,收信人通信地址这两 ...

  8. Java 之 I/O 系列 02 ——序列化(二)

    Java 之 I/O 系列 目录 Java 之 I/O 系列 01 ——基础 Java 之 I/O 系列 02 ——序列化(一) Java 之 I/O 系列 02 ——序列化(二) 继续上篇的第二个问 ...

  9. javascript中IE与ff的区别

    1.自定义属性问题:可以使用获取常规属性的方法来获取自定义属性,也可以使用getAtribute()获取自定义属性,ff下只能使用getAttribute()获取自定义属性. 2. 在IE中可以用ev ...

  10. HDU 1171(01背包)

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...