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

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. Linux系统启动流程(2)

    内核设计风格: RedHat, SUSE核心:动态加载 内核模块内核:/lib/modules/“内核版本号命令的目录”/vmlinuz-2.6.32/lib/modules/2.6.32/ RedH ...

  2. cStringIO模块例子

    # Vorbis comment support for Mutagen # Copyright 2005-2006 Joe Wreschnig # # This program is free so ...

  3. [[UIScreen mainScreen] scale]详解

    [[UIScreen mainScreen] scale]详解 当屏幕分别为640x940时[[UIScreen mainScreen] scale]=2.0 当屏幕分别为320x480时[[UISc ...

  4. jQuery Pagination Ajax分页插件中文详解(摘)

    jQuery Pagination Ajax分页插件中文详解 by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxin ...

  5. 【SVN Working copy is too old (format 10, created by Subversion 1.6)】解决方式

    SVN同步或者提交的时候出现类似错误信息: The working copy needs to be upgraded svn: Working copy 'D:\adt-bundle-windows ...

  6. LR选择哪种方式录制

    LR选择哪种方式录制,有以下考虑原则: 1.基于浏览器的应用程序推荐使用HTML-basic script方式录制 2.不是基于浏览器的应用程序推荐使用URL-basic script方式录制 3.如 ...

  7. HTTP协议5之代理--转

    代理服务器 Web代理(proxy)服务器是网络的中间实体. 代理位于Web客户端和Web服务器之间,扮演“中间人”的角色. HTTP的代理服务器即是Web服务器又是Web客户端. Fiddler就是 ...

  8. [转]Asp.Net调用前台js调用后台代码分享

    1.C#前台js调用后台代码 前台js <script type="text/javascript" language="javascript"> ...

  9. Code Complete阅读笔记(二)

    2015-03-06   328   Unusual Data Types    ——You can carry this technique to extremes,putting all the ...

  10. SQL SERVER 清空日志

    DUMP TRANSACTION [TBNAME] WITH NO_LOGBACKUP LOG [TBNAME] WITH NO_LOGDBCC SHRINKDATABASE([TBNAME]) 1. ...