#include <iostream>
#include<iomanip>
#include<cstring>
using namespace std;
int s;
void chen(char a[],char b[])//a=a*b
{ int i,j,k,l,sum,c[]={};
l=strlen(a)+strlen(b);
for(i=strlen(b)-;i>=;i--)
for(j=strlen(a)-,k=i+j+;j>=;j--,k--)
{ sum=(b[i]-'')*(a[j]-'')+c[k];
c[k]=sum%;c[k-]+=sum/;
}
for(i=c[]?:,j=;i<l;i++)
a[j++]=(c[i]+''); a[j]=;
}
void quw0(char a[]) //去除尾部多余的零
{ int i=strlen(a)-;
while(a[i]=='') {a[i]=;i--;}
} void jilu(char a[])
{ int i,t;
for(i=;i<strlen(a);i++) //判断有没有小数点
if(a[i]=='.') break;
if(i!=strlen(a)) //有小数点
{
for(i=strlen(a)-,s=;i>=;i--)// s记录小数位数
if(a[i]!='.') s++;
else break;
if(a[i=]=='') // 0.0123变成123
{ for(i=;i<strlen(a);i++)
if(a[i]!='') {strcpy(a,&a[i]);break;}
}
else //将1.4321 变成14321
{ for(t=,i=;i<strlen(a)-;i++)
{ if(a[i]=='.') t=;
if(t) a[i]=a[i+];
}
a[i]=;
}
} } void show(char a[])
{ int i;
if(s>=strlen(a)) cout<<'.'<<setfill('')<<setw(s)<<a<<endl;// 前面补零
else //不用补零,直接加入小数点输出
{for(i=;i<strlen(a);i++)
if(strlen(a)-s==i) {cout<<'.'<<&a[i]; break;}
else cout<<a[i];
cout<<endl;
} } int main()
{
int n; char b[],a[];
while(cin>>b>>n)
{ if(n==) {cout<<<<endl;continue;}
s=;
quw0(b);
jilu(b);
strcpy(a,b);
for(int i=;i<=n;i++)
chen(a,b);
s*=n; //结果的小数位数
show(a);
}
return ;
}

poj1001的更多相关文章

  1. 高精度POJ1001

    今天看到这道题了 poj1001 题目地址是http://bailian.openjudge.cn/practice/1001/ 英文看得懂,可是算法不明白,所以转别人的文章,留着给学生看看:乔高建( ...

  2. POJ-1001 Exponentiation 高精度算法

    题目链接:https://cn.vjudge.net/problem/POJ-1001 以前写过一个高精度乘法,但是没有小数点,实现起来也没什么难得, 现在把代码都般过来,等会把旧电脑弄一弄,暂时就不 ...

  3. poj1001 Exponentiation 大数的幂

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

  4. 【poj1001】 Exponentiation

    http://poj.org/problem?id=1001 (题目链接) 题意 求实数R的n次方,要求高精度. Solution SB题Wa了一下午,直接蒯题解. 高精度,小数点以及去前导后导零很麻 ...

  5. 北大poj-1001

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

  6. poj1001 Exponentiation

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

  7. C# 高精度求幂 poj1001

    高精度求幂 public static char[] exponentiation(string a,int r) { ]; string b = ""; string c = a ...

  8. poj1001(高精度)

                                                               Exponentiation Time Limit: 500MS   Memory ...

  9. poj1001求幂

    这道题目是实质上就是高精度的乘法,虽然是带小数点的数多少次幂,但是开始我们需要将它变为整数进行求幂,然后再加上小数点,然后要考虑前导0,有效数位问题,做的时候要十分的小心 #include<io ...

随机推荐

  1. Web性能和负载测试工具补充

    压力测试文档:https://yq.aliyun.com/articles/377543https://www.cnblogs.com/ahjxxy/archive/2012/09/17/268899 ...

  2. Python Day 8

    阅读目录:   内容回顾 三种字符串 文件操作三步骤 基础的读 基础的写 with...open()语法 文件的操作模式 文件的操作编码问题 文件的复制 游标操作 ##内容回顾 类型转换 #1.数字类 ...

  3. 谷歌浏览器运行Flash

    最近有人问我谷歌浏览器的flash总是要点击手动运行才可以使用.看了很多网上很多教程,并没有比较好的解决方案. 自己找了相关资料后,找到了一个比较好的完整的.特此在这边放出来给大家使用. 新建记事本, ...

  4. requests+正则爬取猫眼电影前100

    最近复习功课,日常码农生活. import requests from requests.exceptions import RequestException import re import jso ...

  5. pt-query-digest 使用说明

    pt-query-digest --user=anemometer --password=123456 --socket=/tmp/mysql.sock --port=43306 --review h ...

  6. vscode 添加 includePath

    使用vscode打开C项目时,vscode无法找到头文件路径,提示:configure includePath for better intellisense results 解决: 编辑~/.vsc ...

  7. ruby module extend self vs module_funciton

    最近学习ruby过程中,extend self 跟 module_function 傻傻分不清楚,查资料后明白之间的差别,虽记录之,原文地址 github module A extend self d ...

  8. OpenCV3.30 画图函数

    画图函数(Draw Functions)都放在imgpro. 例如C++中用: #include <opencv2\imgproc.hpp>

  9. easyUI分页实现加搜索功能

    前台页面: js代码: ps:pagination为true时会在table下面加上easyUI的分页. load函数会将查询值传给datagrid并传给后台重新加载. DAO.xml为: 后台代码实 ...

  10. hadoop配置笔记

    接上回,hadoop的配置文件都在下载的压缩包目录中的etc/hadoop/中 hadoop-env.sh有个地方配置java_home 其他常用的设置文件有: core-site.xml yarn- ...