The "A+B problem" is very easy,but I failed for many times.

The code:

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<iomanip>
#define LL long long
#define MAXN 50001
#define P 123456
using namespace std;
int a[P],b[P],c[P],ka=,kb=;
char ca[P],cb[P];
int main()
{
scanf("%s%s",ca,cb);
int lena=strlen(ca),lenb=strlen(cb);
int j=;
for(int i=lena-;i>=;i--)
{
a[ka]+=j*(ca[i]-'');
j*=;
if(j==)
j=,ka++;
} if(j!=)
ka++,j=;
for(int i=lenb-;i>=;i--)
{
b[kb]+=j*(cb[i]-'');
j*=;
if(j==)
j=,kb++;
}
if(j!=)
kb++,j=; //a[],b[] finish int e=;
for(int i=;i<=max(ka,kb);i++)
{
c[i]=(a[i]+b[i]+e)%;
e=(a[i]+b[i]+e)/;
}
int k=max(ka,kb)+;
while(k>&&!c[k]) k--;
printf("%d",c[k]);
for(int i=k-;i>=;i--)
printf("%03d",c[i]); return ;
}

I have forgot to plus the "e" first, so I have so much mistake!!!

A+B problem (High-precision)的更多相关文章

  1. HDU 2256 Problem of Precision(矩阵)

    Problem of Precision [题目链接]Problem of Precision [题目类型]矩阵 &题解: 参考:点这里 这题做的好玄啊,最后要添加一项,之后约等于,但是有do ...

  2. HDU 2256 Problem of Precision (矩阵乘法)

    Problem of Precision Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  3. HDU 2256 Problem of Precision (矩阵快速幂)(推算)

    Problem of Precision Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  4. HDU 2256 Problem of Precision 数论矩阵快速幂

    题目要求求出(√2+√3)2n的整数部分再mod 1024. (√2+√3)2n=(5+2√6)n 如果直接计算,用double存值,当n很大的时候,精度损失会变大,无法得到想要的结果. 我们发现(5 ...

  5. HDU 2256 Problem of Precision (矩阵快速幂)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2256 最重要的是构建递推式,下面的图是盗来的.貌似这种叫共轭数. #include <iostr ...

  6. hdu 2256 Problem of Precision 构造整数 + 矩阵快速幂

    http://acm.hdu.edu.cn/showproblem.php?pid=2256 题意:给定 n    求解   ? 思路: , 令  , 那么 , 得: 得转移矩阵: 但是上面求出来的并 ...

  7. hdu 2256 Problem of Precision

    点击打开hdu 2256 思路: 矩阵快速幂 分析: 1 题目要求的是(sqrt(2)+sqrt(3))^2n %1024向下取整的值 3 这里很多人会直接认为结果等于(an+bn*sqrt(6))% ...

  8. HDU 2256 Problem of Precision(矩阵高速幂)

    题目地址:HDU 2256 思路: (sqrt(2)+sqrt(3))^2*n=(5+2*sqrt(6))^n; 这时要注意到(5+2*sqrt(6))^n总能够表示成an+bn*sqrt(6); a ...

  9. HDU 2256 Problem of Precision( 矩阵快速幂 )

    链接:传送门 题意:求式子的值,并向下取整 思路: 然后使用矩阵快速幂进行求解 balabala:这道题主要是怎么将目标公式进行化简,化简到一个可以使用现有知识进行解决的一个过程!菜的扣脚...... ...

  10. hdu 5451 Best Solver 矩阵循环群+矩阵快速幂

    http://acm.hdu.edu.cn/showproblem.php?pid=5451 题意:给定x    求解 思路: 由斐波那契数列的两种表示方法, 之后可以转化为 线性表示 F[n] = ...

随机推荐

  1. Sping--AOP--Annotation

    Aspectj 概念: 1. joinpoint:切入点, 比如@Before, @After, @Around 2. Pointcut:切入点集合, 比如 @Pointcut("execu ...

  2. CDOJ 1273 God Qing's circuital law

    暴力枚举+idea.做的时候mod写错了,写成了1000000009,找了两个多小时才发现...... a[1],a[2],a[3]....a[N] b[1],b[2],b[3]....b[N] 首先 ...

  3. (简单) POJ 1961 Period,扩展KMP。

    Description For each prefix of a given string S with N characters (each character has an ASCII code ...

  4. [iOS Animation]-CALayer 图层树

    图层的树状结构 巨妖有图层,洋葱也有图层,你有吗?我们都有图层 -- 史莱克 Core Animation其实是一个令人误解的命名.你可能认为它只是用来做动画的,但实际上它是从一个叫做Layer Ki ...

  5. LED调光,PFM即pulse frequence modulation

    PWM不是唯一的调制方式,可以PWM,也可以PFM,也可以混合调制. PWM即pulse width modulation的缩写,脉冲宽度调制,保持开关周期不变,调节开关导通时间. PFM即pulse ...

  6. 基于FPGA的OLED真彩色动态图像显示的实现

    源:基于FPGA的OLED真彩色动态图像显示的实现 作为第3代显示器,有机电致发光器件(Organic Light Emitting Diode,OLED)由于其主动发光.响应快.高亮度.全视角.直流 ...

  7. 解决word启动时报找不到mathpage.wll错误

    按下面的网址进行操作即可: http://www.mathtype.cn/wenti/word-jianrong.html

  8. UVa 324 - Factorial Frequencies

    题目大意:给一个数n,统计n的阶乘中各个数字出现的次数.用java的大数做. import java.io.*; import java.util.*; import java.math.*; cla ...

  9. js 设置导航固定

    <div id="nav"> .... </div> function Add_Data() { var top = $("#header-nav ...

  10. ul中li分列显示

    让ul中li分列显示,用li显示两列如下(要显视多列的自己想办法,哈哈): 2列 <ul> <li style="display:block;float:left;widt ...