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. linux redis 安装

    linux下redis安装   我用的系统是:redhat [root@infa ~]# wget http://download.redis.io/releases/redis-2.8.12.tar ...

  2. js高级程序设计(三)基本概念

    数据类型 ECMAscript中有五种简单数据类型Undefined,Null,Boolean,Number,String 还有一种复杂数据类型Object. typeof操作符 typeof可能返回 ...

  3. js键盘操作事件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 错误:Error:未定义标识符"_TCHAR"

    原因:缺少头文件 解决方案:添加一条 #include <tchar.h>

  5. Hibernate缓存机制

    缓存是介于应用程序和物理数据源之间,其作用是为了降低应用程序对物理数据源访问的频次,从而提高了应用的运行性能.缓存内的数据是对物理数据源中的数据的复制,应用程序在运行时从缓存读写数据,在特定的时刻或事 ...

  6. 转载:Clear Float

    众所周知,平时在写HTML代码时,难免少不了使用Float样式,这样一来,假使您没有清除浮动,那么有浮动元素的父元素容器将元素将无法自动撑 开.换句简单好理解的话来说,假如你在写CODE时,其中div ...

  7. ZZC语言代码风格

    程序员之路--关于代码风格 优秀的代码风格如同一身得体的打扮,能够给人以良好的印象.初学程序设计,首先必须建立良好的编程习惯,这其中就包括代码风格.本文就代码风格中的几个重点问题进行了讨论,并在文后给 ...

  8. 修改weblogic部署的应用名称

    通过weblogic管理后台console进行发布本地项目的时候,它会默认以WEB-INF的上一级目录作为访问路径,如,假如你的项目WEB-INF目录的上一层是WebRoot,那么发布后,访问的路径默 ...

  9. Hadoop作业JVM堆大小设置优化 [转]

    前段时间,公司Hadoop集群整体的负载很高,查了一下原因,发现原来是客户端那边在每一个作业上擅自配置了很大的堆空间,从而导致集群负载很高.下面我就来讲讲怎么来现在客户端那边的JVM堆大小的设置.我们 ...

  10. hadoop版本比较 [转]

    由于Hadoop版本混乱多变,因此,Hadoop的版本选择问题一直令很多初级用户苦恼.本文总结了Apache Hadoop和Cloudera Hadoop的版本衍化过程,并给出了选择Hadoop版本的 ...