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. LaTeX内容总结

    欢迎关注我的社交账号: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://gith ...

  2. Android Studio Gradle构建脚本

    Gradle是一种依赖管理工具,基于Groovy语言,面向Java应用为主,它抛弃了基于XML的各种繁琐配置,取而代之的是一种基于Groovy的内部领域特定(DSL)语言. 构建工具就是对你的项目进行 ...

  3. 静态类和静态类成员(C# 编程指南)

    静态类与非静态类基本相同,但存在一个区别:静态类不能实例化. 也就是说,不能使用 new 关键字创建静态类类型的变量. 因为没有实例变量,所以要使用类名本身访问静态类的成员. 例如,如果名为 Util ...

  4. javascript 盒子模型

    oDiv.clientWidth--->width+左右padding oDiv.clientHeight--->height+上下padding oDiv.clientTop---> ...

  5. Python 练习 11

    #!/usr/bin/python # -*- coding: UTF-8 -*- import math for i in range(10000): #转化为整型值 x = int(math.sq ...

  6. S2 第三章SQL编程

    .if练习 --统计并显示2013-- 的oop考试平均分 --如果平均分在70以上,显示“考试成绩优秀”,并显示前三名学生的考试信息 --如果在70分以下,显示“考试成绩较差”,并显示后三名学生的考 ...

  7. ARM的启动和中断向量表

    启动的方式 对于S3C2440而言,启动的方式有两种,一是Nor Flash方式启动,二是Nand Flash方式启动. 使用Nor Flash方式启动 Nor Flash的地址范围如下 0x0000 ...

  8. 数据库索引<二> 如何创建索引

    前面一篇说法了索引结构,和几种索引在数据表上的结构,了解了索引可以为查询服务,这篇说一说如何创建索引. >平时可能的创建方式 这个系统中要用到A字段,B字段,C字段做为查询的条件,联接的条件较多 ...

  9. this和super关键字

    this关键字: 1.引用成员变量 2.通过this(参数列表)调用类的重载的构造方法 3.返回对象的值:使用return this,来返回某个类的引用. super关键字: 1.super是一个引用 ...

  10. mrg_myIsam分表引擎用法

    CREATE TABLE `test`.`article_0` ( `id` BIGINT( 20 ) NOT NULL , `subject` VARCHAR( 200 ) NOT NULL , ` ...