#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>using namespace std;char a[1010],b[1010];int ta[1010],tb[1010];int main(){ int l2,l1,l; while(scanf("%s%s",a,b)!=EOF) { memset(ta,0,sizeof(ta)); m…
理解 vector 是一个容器,是一个数据集,里边装了很多个元素.与数组最大的不同是 vector 可以动态增长. 用 vector 实现大数运算的关键是,以 string 的方式读入一个大数,然后将字串的每一个字符 s[i] 以 int 形式赋给 vector<int> a 中的每一个元素.然后将 a[i] 和 a[j] 加起来(或者乘起来).每两个元素加起来的结果 <= 18,乘起来的结果 <= 81. 用 string 实现大数加法的方法跟 vector 差不多,但是用 st…
北大的ACM 1001 poj.org/problem?id=1001 代码纯手动编写 - - #include <iostream> #include <cstdio> #include <cstring> class BigNumber { struct BigNumberNode { BigNumberNode():n(0), prev(NULL), next(NULL){} BigNumberNode(int N):n(N), prev(NULL), next(…
http://acm.hdu.edu.cn/showproblem.php?pid=1002 A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 261608    Accepted Submission(s): 50625 Problem Description I have a very simple p…
A+B and A*B problem 大数相加 相乘 模拟 题意 给你两个数a和b,这两个数很大,然后输出这两个数相加的和,相乘的积. 解题思路 模拟,但是还是搜了搜代码实现,发现这个大佬写的是真的简洁高效. 下面第一个代码转自博客(修改了一些) >>>https://blog.csdn.net/hacker00011000/article/details/51298294 第二个代码是CZH同学的代码,代码更是简单易懂! 别的一些思路 大数相加相乘 https://blog.csdn…
题目描述: Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should n…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1002 题意: 数学题,A+B; 思路,这个数非常大,普通加法一定会超时,所以用大数加法.大数加法的基本思路是模拟我们做加法的时候的进位思想,从最低位开始模拟, 在我的代码里 v -- 进位, tmp -- 当前位2个数的和,k -- 答案数组的下标. 其中, tmp/10 可以得到要进的位数, 同理,tmp%10可以得到个位,就是答案数组对应的位 下面是AC代码: #include <iostre…
题目链接>>>>>> 题目大意:手动模拟大数加法,从而进行两个大数的加法运算 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define MAXN 3000 int a[MAXN], b[MAXN]; int main() { int t; scanf(; getchar(); int array[MAXN]; whi…
解题思路 两个⼤数可以⽤数组来逐位保存,然后在数组中逐位进⾏相加,再判断该位相加后是否需要进位.为了⽅便计算,可以把数字的低位放到数组的前面,高位放在后面. 样例输入 3 18 22 56 744 53234673473 7544645548767 样例输出 Case 1: 18 + 22 = 40 Case 2: 56 + 744 = 800 Case 3: 53234673473 + 7544645548767 = 7597880222240 代码实现 #include<stdio.h>…
题目连接:http://www.ifrog.cc/acm/problem/1056 DESCRIPTION Two octal number integers a, b are given, and you need calculate the result a - b in octal notation.If the result is negative, you should use the negative sign instead of complement notation. INPU…