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. 绿色版Tomcat 启动 + 停止 + 随系统自动启动 - - 博客频道 - CSDN.NET

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  2. (简单) POJ 3254 Corn Fields,状压DP。

    Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; ...

  3. RestTemplate 发送Post 多个参数请求

    MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>(); requestEntity ...

  4. codeforces #304 DIV2

    先送上一篇题解(虽然全英文的):http://codeforces.com/blog/entry/18034 A题:http://codeforces.com/problemset/problem/5 ...

  5. mysql优化------2 查看系统性能(表大小,I/o性能)

    三:判断mysql I/0 性能的一种方式(网络搜集供参考) show global status like 'innodb_dblwr%'\G   如果innodb_dblwr_pages_writ ...

  6. HDU 3264 Open-air shopping malls ——(二分+圆交)

    纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...

  7. 【java基础】接口VS抽象类

    1.至少有一个被abstract修饰的方法,同时修饰类名的类为抽象类,抽象的方法必须被子类覆盖,抽象的类必须被继承,抽象的类可以包含非抽象方法,只能单继承. 2.接口中所有的变量是static fin ...

  8. 用Django Rest Framework和AngularJS开始你的项目

    Reference: http://blog.csdn.net/seele52/article/details/14105445 译序:虽然本文号称是"hello world式的教程&quo ...

  9. 高仿xx教育网

    2014年2月26日 16:24:50 好久没做 php了,考虑到老婆是教育行业,高仿一个教育辅导机构的网站 加油

  10. CSS3动画效果——js调用css动画属性并回调处理详解

    http://www.jb51.net/css/258407.html 这篇文章主要详细介绍了CSS3动画效果回调处理,需要的朋友可以参考下 我们在做js动画的时候,很多时候都需要做回调处理,如在一个 ...