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 \le 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 Rn. Leading zeros and insignificant trailing zeros should be suppressed in the output.

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
思路:注意当输入1.10000时我是先变成1.1处理

#include<stdio.h>
#include<iostream>
using namespace std;
#include<string.h>
void chengfa(char a[],char b[])
{
int sum[];
int lena=strlen(a)-;
int lenb=strlen(b)-;
int t1=lena;
int t;
memset(sum ,,sizeof(sum));
for(int i=lena;i>=;i--)
for(int j=lenb,t=-(t1-i);j>=;j--)
sum[t--]+=(a[i]-'')*(b[j]-'');
for(int k=;k>=;k--)
{
sum[k-]+=sum[k]/;
sum[k]=sum[k]%;
}
int start=;
while(start<=&&!sum[start])
start++;
memset(a,,sizeof(a));
int t2=;
for(int k=start;k<=;k++)
a[t2++]=sum[k]+'';
a[t2]='\0'; }
int main()
{
char a[],b[];
char a1[],a2[];
int n;
memset(b,,sizeof(b));
while(cin>>a>>n)
{
int k6;
int len6=strlen(a);
for(k6=len6-;k6>=;k6--)
if(a[k6]!='')
{
a[k6+]='\0';
break;
}
int len1=strlen(a);
int k;
for(int i=;i<len1;i++)
if(a[i]=='.')
{ k=(len1-)-i;
int j;
for(j=i;j<len1;j++)
a[j]=a[j+];
a[j]='\0';
len1--;
break; }
int num=k*n;
strcpy(b,a);
n=n-;
while(n--)
chengfa(a,b);
int len2=strlen(a);
int count1=;
int k1,k2,k3,k4;
int lena=strlen(a)-count1;
if(num<lena) 没有前导0,即第一个是数字是大于0
{
for(k1=;k1<lena-num;k1++)
cout<<a[k1];
cout<<'.';
for(k2=k1;k2<lena;k2++)
cout<<a[k2];
cout<<endl;
}
else //有前导0
{ printf(".");
for(k3=num-lena;k3>;k3--)
printf("");
cout<<a;
cout<<endl;
}
}
return ;
}

Problem F: Exponentiation大数求幂的更多相关文章

  1. Problem F: Exponentiation

    Problem F: ExponentiationTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 4 Solved: 2[Submit][Status][W ...

  2. poj1001 Exponentiation 大数的幂

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

  3. 实验12:Problem F: 求平均年龄

    Home Web Board ProblemSet Standing Status Statistics   Problem F: 求平均年龄 Problem F: 求平均年龄 Time Limit: ...

  4. 快速求幂(Quick Exponentiation)

    接触ACM没几天,向各路大神求教,听说ACM主要是研究算法,所以便开始了苦逼的算法学习之路.话不多说,RT所示,学习快速求幂. 在头文件<math.h>或是<cmath>中,d ...

  5. 如何运用同余定理求余数【hdoj 1212 Big Number【大数求余数】】

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  6. 求幂大法,矩阵快速幂,快速幂模板题--hdu4549

    hdu-4549 求幂大法.矩阵快速幂.快速幂 题目 M斐波那契数列 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 ...

  7. 大数求模 sicily 1020

        Search

  8. C# 高精度求幂 poj1001

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

  9. 九度OJ 1085 求root(N, k) -- 二分求幂及快速幂取模

    题目地址:http://ac.jobdu.com/problem.php?pid=1085 题目描述: N<k时,root(N,k) = N,否则,root(N,k) = root(N',k). ...

随机推荐

  1. php的stdClass类

    在PHP内核进行模块初始化操作时会自动加载这个函数, 这样,stdClass类的注册操作也就会被执行了.stdClass类是一个没有成员变量也没有成员方法的类. 它的所有的魔术方法,父类.接口等在初始 ...

  2. C#反射概念以及实例详解【转】

    2009-08-28 13:12 佚名 互联网 我要评论(1) 字号:T | T C#反射概念以及实例向你介绍了C#反射的基本内容以及C#反射实例的简单应用,希望对你了解和学习C#反射以及C#反射实例 ...

  3. Nginx基础教程PPT

    Nginx基础教程PPT By 马冬亮(凝霜  Loki) 一个人的战争(http://blog.csdn.net/MDL13412) pdf版本号下载 watermark/2/text/aHR0cD ...

  4. DOM注意事项(八):JavaScript操作环境和垃圾收集

    一.运行环境 在约JavaScript对象或this当指向问题,念就是运行环境.即上下文环境.运行环境在JavaScript是一个非常重要的概念.由于它定义了变量或函数有权訪问的其他数据,决定了它们各 ...

  5. CSS权威指南学习笔记 —— HTML元素分类

    HTML文档由各种元素组成.比如,p.table.span等等.每个元素都会对文档的表现有所影响.CSS中,每个元素都会生成一个框(传说中的盒子),其中包含元素内容. 元素可以根据它的创建方式分为两种 ...

  6. sql server 日期处理datediff

    语法: DATEDIFF(datepart,startdate,enddate) datepart 参数可以是下列的值: date-part : year | quarter | month | we ...

  7. Memcached管理

    安装memcached服务端: apt-get install memcached 配置文件存在于: /etc/memcached.conf 启动memcache: memcached -d -m - ...

  8. 场景:A-->B-->C 跳转到C时,要关掉B的处理方法

    场景:A-->B-->C 跳转到C时,要关掉B的处理方法:相当于从A跳转到C UIViewController *preController = [self.navigationContr ...

  9. EC读书笔记系列之15:条款32、33、34

    条款32 确保你的public继承塑模出is-a关系 记住: ★public继承意味着is-a.适用于base class身上的每一件事情一定也适用于derived class身上,∵每一个deriv ...

  10. [转]前端CSS规范整理

    一.文件规范 1.文件均归档至约定的目录中. 具体要求通过豆瓣的CSS规范进行讲解: 所有的CSS分为两大类:通用类和业务类.通用的CSS文件,放在如下目录中: 基本样式库 /css/core  通用 ...