1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <algorithm>
#include <cstring>

#include <cstdio>
#include <unordered_set>
#include <queue>


using namespace std;

int main()
{
	char* A= new char[5002], *B = new char[5002];
	A[0] = B[0] = '0';
	scanf("%s", A + 1);
	scanf("%s", B + 1);
	int a = strlen(A), b = strlen(B);
	if (a < b)
	{
		int t = a; a = b; b = t;
		char* ts = A; A = B; B = ts;
	}
	a--; b--;
	int over = 0;
	while (a > 0)
	{
		if (b > 0)
		{
			A[a] += (B[b] - '0');
		}

		A[a] += over;


		if (A[a] > '9')
		{
			A[a] -= 10;
			over = 1;
		}
		else
		{
			over = 0;
		}

		a--; b--;
	}
	
	if (over)
	{
		A[a] = '1';
	}
	if(A[0]!='0')
	{
		printf("%s", A);
	}
	else
	{
		printf("%s", A + 1);
	}

	delete[] A;
	delete[] B;
	
	return 0;
}