北大ACM(POJ1001-Exponentiation)
Question:http://poj.org/problem?id=1001
问题点:大数运算(求幂)
#include <iostream>
using namespace std;
#define max 1000
char a[max];
char b[max];
char c[max];
int main()
{
memset(a,,*sizeof(char));
memset(b,,*sizeof(char));
memset(c,,*sizeof(char));
char *R=(char *)malloc(*sizeof(char));
int n,point;
while(cin>>R>>n)
{
for(int i=,j=;i>=;i--,j++)
{
if(R[i]=='.')
{
point=-i;
j--;
continue;
}
a[j]=R[i];
b[j]=R[i];
} if(n==)
{
strcpy(c,a);
}
else
{
for(int k=;k<n;k++)
{
int alen=strlen(a);
int blen=strlen(b);
int m,n;
int jw=;
for(m=;m<alen+blen;m++)
{
int temp=;
for(n=((m-blen+)>?(m-blen+):);n<alen&&m-n<blen&&m-n>=;n++)
{
temp+=(a[n]-'')*(b[m-n]-'');
}
temp+=jw;
jw=temp/;
temp%=;
c[m]=temp+'';
}
strcpy(a,c);
}
}
int slen=strlen(c);
int q;
for(q=strlen(c)-;c[q]==''&&q>=point*n;q--)
{
c[q]=;
}
for(q=;c[q]==''&&q<point*n;q++)
{
}
for(int p=strlen(c)-;p>=q;p--)
{
if(p==point*n-)
{
cout<<".";
}
cout<<c[p];
}
memset(a,,*sizeof(char));
memset(b,,*sizeof(char));
memset(c,,*sizeof(char));
cout<<endl;
}
return ;
}
北大ACM(POJ1001-Exponentiation)的更多相关文章
- 北大 ACM 分类 汇总
1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- 北大ACM题库习题分类与简介(转载)
在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------- ...
- poj1001 Exponentiation【java大数】
Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 183034 Accepted: 44062 ...
- POJ-1001 Exponentiation 高精度算法
题目链接:https://cn.vjudge.net/problem/POJ-1001 以前写过一个高精度乘法,但是没有小数点,实现起来也没什么难得, 现在把代码都般过来,等会把旧电脑弄一弄,暂时就不 ...
- 北大ACM试题分类+部分解题报告链接
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- 北大ACM - POJ试题分类
1.入门水题 可用于练手与增强自信 POJ-1003POJ-1004 POJ-1005 POJ-1207 POJ-3299 POJ-2159 POJ-1083POJ-3094 2.初级 2.1. 基本 ...
- poj1001 Exponentiation 大数的幂
Description Problems involving the computation of exact values of very large magnitude and precision ...
- 北大ACM(POJ1014-Dividing)
Question:http://poj.org/problem?id=1014 问题点:抽屉原理.dfs.多重背包. Memory: 248K Time: 16MS Language: C++ Res ...
- 北大ACM(POJ1013-Counterfeit Dollar)
Question:http://poj.org/problem?id=1013 问题点:排除+验证. Memory: 244K Time: 16MS Language: C++ Result: Acc ...
随机推荐
- android studio 2.0 Gradle HttpProxy 设置
Android Studio 一直Failed to import Gradle project: Connection timed out: connect Android Studio 2.0 里 ...
- Codeforces Round #277 (Div. 2) B. OR in Matrix 贪心
B. OR in Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/probl ...
- Codeforces Round #274 (Div. 1) B. Long Jumps 数学
B. Long Jumps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/ ...
- IE8不显示字体图标
bootstrap流行,随着自带的字体图标也火起来了.美丽的字体系统中没有.制作成字体文件,下载到本地.浏览美丽的网页哦. 在项目中遇到有些IE8显示不了,原因是IE8下设置了禁止字体下载
- hdu4864 hdu4268 贪心 lower_bound
hdu4864 题意: 有n个机器,m个任务,n,m<=100000,每个机器都有工作时间的最大限制xi(0<xi<1440)和完成的最大难度yi(0<=yi<=100) ...
- 分享一个圆角自定义的漂亮AlertDialog
\res\drawable-hdpi\bg_title_custom_dialog.xml: <?xml version="1.0" encoding="utf-8 ...
- [Redux] Accessing Dispatch and State with Redux -- connect
If you have props and actions, you want one component to access those props and actions, one solutio ...
- 文献阅读笔记——group sparsity and geometry constrained dictionary
周五实验室有同学报告了ICCV2013的一篇论文group sparsity and geometry constrained dictionary learning for action recog ...
- mybatis0212 mybatis逆向工程 (MyBatis Generator)
1mybatis逆向工程 (MyBatis Generator) .1什么是mybatis的逆向工程 mybatis官方为了提高开发效率,提高自动对单表生成sql,包括生成 :mapper.xml.m ...
- BEA WebLogic Server 10 查看和配置日志
查看和配置日志 WebLogic Server 内的每个子系统都可生成日志消息来传达其状态.例如,当启动 WebLogic Server 实例时,安全子系统会输出消息以报告其初始化状态.为了记录其子系 ...