-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHUSODAUTIENPOW.cpp
63 lines (57 loc) · 1.2 KB
/
CHUSODAUTIENPOW.cpp
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
#include <iostream>
#include <math.h>
using namespace std;
string Cong(string a, string b)
{
int len = max(a.length(), b.length());
while (a.length()<len)
a="0"+a;
while (b.length()<len)
b="0"+b;
/*
a = 123
b = 4567
->
a = 0123
b = 4567
*/
string rs = "";
int remember = 0;
for (int i=len-1; i>=0; i--)
{
int n1 = a[i]-'0';
int n2 = b[i]-'0';
int s = n1+n2+remember;
char rs_tmp = s%10 + '0';
rs = rs_tmp + rs;
remember = s/10;
}
if (remember!=0)
return char(remember+'0')+rs;
return rs;
}
string luythua(string x, int n, int d)
{
if (n==0) return "1";
else if (n==1) return x;
string rs = x;
for (int i=2; i<=n; i++)
{
string rs_tmp = rs;
for (int j=2; j<=d; j++)
{
rs = Cong(rs, rs_tmp); //2^3 = ((2)*2)*2 = ((2)+(2))+((2)+(2))
}
}
return rs;
}
int main()
{
int n, m;
cin>>n>>m;
string lt2 = luythua("2", n, 2);
string lt3 = luythua("3", m, 3);
string S = Cong(lt2, lt3);
cout<<S[0];
return 0;
}