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. 关于WorkFlow的使用以及例子

    近期做项目,项目需要用到工作流方面的技术,我在这里与大家分享一个workFlow学习的地址,共大家学习. http://www.cnblogs.com/foundation/ 各文档的说明: F资料├ ...

  2. JAVA_安装JDK和Eclipse

    大二开始前,找的是学长帮忙直接安装的,这个寒假抽空体验重装系统,同时,体验安装JDK和Eclipse.O(∩_∩)O 1.jdk 1)官方网址(下载JDK)   http://www.oracle.c ...

  3. ERP开发分享 1 数据库表设计

    这是我的ERP设计经验分享系列,今天讲的是数据库的表设计(1),主要阐述: 1.单字段的主键:2.使用int32作为主键类型:3.使用版本字段处理乐观锁定:4.生效字段标明是否允许“被使用”:5.锁定 ...

  4. Java集合——List接口

    1.定义 List是Collection的子接口,元素有序并且可以重复,表示线性表. 2.方法 add(int index,Object e):在指定索引(和数组下标类似,为0,1,2....)放入元 ...

  5. Mysql多表关联删除操作

    直接看Sql即可: ;

  6. JDE处理选项

    处理选项为JDE的一种数据结构,命名方式如下: The name of a data structure can be a maximum of characters-only if you begi ...

  7. eval()函数使用

    条件:有数据集data[indx],数据集内含有对象data[index].obj1.pama1. 说明:传入参数为var str = 'obj1.pama1',要求取得data[index].obj ...

  8. c++读入之 -- 汉字读入遇到的问题

    好吧,课题和汉语处理有关,于是就要求用c++来读入汉字进行处理. 首先使用wchar_t字符即宽字符,然后这样定义: #include <cstdio> #include <cwch ...

  9. apache2.4域名配置参数

    apache2.4和 2.2版本的配置有区别 2.4的配置如下 <VirtualHost *:80>DocumentRoot /www/web/projectServerName www. ...

  10. 如何创建一个客户端回调:js获得服务端的内容?

    答案:表面上看去就是前端的js调用服务的C#方法,本质就是ajax,通过XMLHttpRequest对象和服务端进行交互.回调:就说回过头来调用,按理说js是一种脚本语言,怎么能用来调用服务端的呢?就 ...