本题的测试用例十分刁钻,必须要考虑到很多的细节问题,在这里给出一组测试用例及运行结果:

95.123 12

548815620517731830194541.899025343415715973535967221869852721

0.4321 20
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
5.1234 15
43992025569.928573701266488041146654993318703707511666295476720493953024
6.7592 9
29448126.764121021618164430206909037173276672
98.999 10
90429072743629540498.107596019456651774561044010001
1.0100 12
1.126825030131969720661201
.00001 1
.00001
.12345 1
.12345
0001.1 1
1.1
1.1000 1
1.1
10.000 1
10
000.10 1
.1
000010 1
10
000.10 1
.1
0000.1 1
.1
00.111 1
.111
0.0001 1
.0001
0.0001 3
.000000000001
0.0010 1
.001
0.0010 3
.000000001
0.0100 1
.01
0.0100 3
.000001
0.1000 1
.1
0.1000 3
.001
1.0000 1
1
1.0000 3
1
1.0001 1
1.0001
1.0001 3
1.000300030001
1.0010 1
1.001
1.0010 3
1.003003001
1.0100 1
1.01
1.0100 3
1.030301
1.1000 1
1.1
1.1000 3
1.331
10.000 1
10
10.000 3
1000
10.001 1
10.001
10.001 3
1000.300030001
10.010 1
10.01
10.010 3
1003.003001
10.100 1
10.1
10.100 3
1030.301
99.000 1
99
99.000 3
970299
99.001 1
99.001
99.001 3
970328.403297001
99.010 1
99.01
99.010 3
970593.059701
99.100 1
99.1
99.100 3
973242.271
99.998 1
99.998
0.0010 1
.001

下面是AC代码:

#include<stdio.h>
#include<string.h>
int c[];
int a[];
int b[];
int lenb,lenxiao,len;
void cal() {//计算部分
int i,j,k; memset(c,,sizeof(c));
if(lenxiao==){
len=;
}
else{
len=;
}
for(i=,k=;i<len;i++){
for(j=;j<lenb;j++){
c[i+j+]+=a[i]*b[j];
}
} for(i=len+lenb-;i>;i--){
if(c[i]>=){
c[i-]+=c[i]/;
c[i]=c[i]%;
}
}
if(c[]==){
for(i=;i<=len+lenb-;i++){
b[i-]=c[i];
}
lenb=len+lenb-;
}
else{
for(i=;i<=len+lenb-;i++){
b[i]=c[i];
}
lenb=len+lenb;
}
} void shuchu(int b[],int lenb){// 输出部分
int i,j;
for(i=;i<lenb-lenxiao;i++){
if(b[i]!=)
{
break;
}
}
if(i==lenb){
printf("0\n");
return;
}
for(j=lenb-;j>=lenb-lenxiao;j--){
if(b[j]!=){
break;
}
}
if(j==i&&b[i]==){
printf("0\n");
return ;
}
for(;i<=j;i++){
if(i==lenb-lenxiao){
printf(".");
}
printf("%d",b[i]);
}
printf("\n");
}
int main(int argc,char ** argv){
int power;
int i,j,k;
char input[];
while(scanf("%s",input)!=EOF){
scanf("%d",&power);
memset(a,,sizeof(a));
memset(b,,sizeof(b));
lenxiao=;
lenb=;len=;
for(i=,j=,lenb=;i<=;i++){ if(input[i]=='.'){
lenxiao = -i;
continue;
}
a[j++]=b[j]=input[i]-;
lenb++;
}
lenxiao*=power;
for(i=;i<power-;i++){
cal();
}
shuchu(b,lenb); }
return ;
}

poj 1001 求高精度幂的更多相关文章

  1. poj 1001 求高精度幂(Java, BigDecimal, pow, hasNext, stripTrailingZeros, toPlainString)

    求高精度幂 Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 180325   Accepted: 43460 Descripti ...

  2. Poj.Grids 2951 浮点数求高精度幂

    2951:浮点数求高精度幂 总时间限制: 1000ms 内存限制: 65536kB 描述 有一个实数 R ( 0.0 < R < 99.999 ) ,要求写程序精确计算 R 的 n 次方. ...

  3. 【ACM】求高精度幂

    题目来源:http://poj.org/problem?id=1001&lang=zh-CN 求高精度幂 Time Limit: 500MS   Memory Limit: 10000K To ...

  4. 求高精度幂(java)

    求高精度幂 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 对数值很大.精度很高的数进行高精度计算是一类十分常见的问题.比如,对国债进行计算就是属于这类问题. 现在要 ...

  5. Exponentiation(求高精度幂)

    Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 175340   Accepted: 42341 ...

  6. 求高精度幂(poj1001)

    Description Problems involving the computation of exact values of very large magnitude and precision ...

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

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

  8. POJ 1001 Exponentiation(大数运算)

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

  9. 【POJ 1001】Exponentiation (高精度乘法+快速幂)

    BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...

随机推荐

  1. UVA10817--状态压缩DP

    第一次做状态压缩dp..没有思路..看书看明白的,不过看完发现汝哥的做法多算了一些东西,完全可以省去不算.. 用两个集合,s1表示恰好有一个人教的科目,s2表示至少有两个人教的科目.d(i,s1,s2 ...

  2. SimHash算法

    短文本合并重复(去重)的简单有效做法 - 旁观者 - 博客园 短文本合并重复(去重)的简单有效做法 SimHash算法 - ACdreamer - 博客频道 - CSDN.NET SimHash算法

  3. 飘逸的python - 性能调优利器profile及其意义

    VIM 的作者Bram Moolenaar在一篇叫高效文本编辑器的7个习惯的ppt中有这么一段话. Three basic steps 1.    Detect inefficiency 2.    ...

  4. Android学习笔记__3__Android应用程序组成

    Android开发必须要了解构造块,Android应用程序是由里有六个重要组成部分组成的,这六种构造块如下:  ◆Activity ◆Intent Receiver ◆Service ◆Content ...

  5. jquery 弹出框 showDialog.js具体用法

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABWwAAAImCAIAAABID1T7AAAgAElEQVR4nO3d329c52Hgff1HvPCNLw

  6. Unity 单元测试(NUnit,UnityTestTools)

    在软件开发中单元测试是非常重要的一个环节, =.=盘子脸去了几家公司都没有单元测试这个概念. 我们的系统虽然从代码看上是分离的, 在多数情况下都需要依赖于其他模块来运行.(单元测试部分内容教我解决这个 ...

  7. python标准库 platform模块

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' #platform #作用:检查底层平台硬件,操作系统和解释器版本信 ...

  8. 年底小回顾(MVC+NHibernate+Jquery+JqueryUI——网站)

    1.附:利用MVC+NHibernate+Jquery+JqueryUI这些技术可以做出一个比较好的前台+后台网站.下面是本人对这些技术的笔记,作为私人年底小结吧.呵呵 好久没写文章了,感觉下不了笔吐 ...

  9. linux TIME_WAIT过多的解决方法

      查看TCP状态:netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'查看SOCKET状态:cat /proc/n ...

  10. ie11加载不了css的问题

    ie11打开页面,竟然一点css都没有加载出来,而且是老大的电脑遇到了这个问题,啃爹啊 上网查资料,做了如下修改: 1.pc端最好不要用h5来写页面,兼容性是个头疼的问题,切记切记(移动端可以用H5来 ...