#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. vue中使用axios

    1.结合vue-axios使用 vue-axios是按照vue插件的方式去写的,那么结合vue-axios就可以使用Vue.use()这个方法import axios from 'axios' imp ...

  2. Python从入门到精通之eighth!

    函数式编程与内置函数 函数作用域: def test1(): print('in the test1') def test(): print('in the test') return test1() ...

  3. 接口约束的另一种方法:Class类的isAssignableFrom

    Class类的isAssignableFrom是个不常用的方法,感觉这个方法的名字取得不是很好,所以有必要在此解析一下,以免在看源码时产生歧义,这个方法的签名如下: public native boo ...

  4. Spring学习-01

    一.Srping 一个轻量级DI.IOC.AOP的容器框架 DI:依赖注入 IOC:控制反转 AOP:面向切面 二.构造器注入 Constructor-arg 属性:index/name/type/r ...

  5. IOS 设置视图半透明子控件不透明

    代码处理: UIColor *color = [[UIColor blackColor] colorWithAlphaComponent:0.6]; self.view.backgroundColor ...

  6. HTTP Status 404 – Not Found

    一般都是配置中的问题,这次发现扫描controller时,自己的包是com.aaa.conlller,而springmvc.xml中扫描的是com.aaa.controller,,多写了一个l

  7. h3c acl配置一列

    acl number 3004 rule 0 permit ip source 10.2.1.4 0 rule 1 deny ip source 192.168.1.91 0 rule 2 deny ...

  8. ps修改图片文字

    原图(机密内容以打马赛克): 需要修改的地方: 1.去除蓝色的线条, 2.改表格的字体 操作: 1.去线条 放大图片,使用魔棒工具选中蓝色点,调节容差,取消连续,然后填充白色,ctrl+delete ...

  9. ruby module extend self vs module_funciton

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

  10. MFC图片操作

    根据MFC要操作图片的来源,可分为以下两类: 一.非动态显示图片(即图片先通过资源管理器载入,有一个固定ID) 二.动态载入图片(即只需要在程序中指定图片的路径即可载入) 一.非动态显示图片 1.传送 ...