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. [接口服务] Jersey Rest Demo

    http://files.cnblogs.com/files/avivaye/RestProject.rar

  2. Unity Invoke 方法

    Invoke() 方法是 Unity3D 的一种委托机制 如: Invoke("a", 5);   它的意思是:5 秒之后调用 a() 方法: 使用 Invoke() 方法需要注意 ...

  3. (29)odoo的可用小图标

    * 系统的小图标都采用了 fontawesome    官网是 http://fontawesome.dashgame.com/    * 运用小图标    # 首先打开官网 http://fonta ...

  4. 第四周 更新Scrum站立会议

    项目名称:连连看游戏(C#) 小组名称:4Boys 小组成员:武志远.李权.张金生.张政 站立会议内容 昨天完成的: 1.张金生主要介绍了自己完成了游戏界面 2.武志远主要负责查阅关于技术方面的资料, ...

  5. socket头文件

    一. 三种类型的套接字:1.流式套接字(SOCKET_STREAM)    提供面向连接的可靠的数据传输服务.数据被看作是字节流,无长度限制.例如FTP协议就采用这种.2.数据报式套接字(SOCKET ...

  6. 盘点几种数据库的分页SQL的写法(转)

    Data序列——盘点几种数据库的分页SQL的写法http://www.cnblogs.com/fireasy/archive/2013/04/10/3013088.html

  7. MVC中使用HTML Helper类扩展HTML控件

    文章摘自:http://www.cnblogs.com/zhangziqiu/archive/2009/03/18/1415005.html MVC在view页面,经常需要用到很多封装好的HTML控件 ...

  8. 使用window.navigator.userAgent属性判断浏览器类型及版本

    使用window.navigator.userAgent属性判断浏览器类型及版本 2011-12-11 22:03:11 window.navigator.userAgent属性包含了浏览器类型.版本 ...

  9. Java集合涉及的类(代码)

    Customer: public class Customer implements Comparable{        private Integer customerId;        pri ...

  10. jQuery学习小结2——动画

    一.基础动画 方法名 说明 show([speed,[easing],[fn]])hide([speed,[easing],[fn]]) speed:三种预定速度之一的字符串("slow&q ...