-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2407.cpp
62 lines (54 loc) · 1.26 KB
/
2407.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
#include <stdio.h>
class BigInteger
{
public:
int length;
char buf[100];
BigInteger() {
length = 1;
for(int i = 0; i < 100; ++i) buf[i] = 0;
}
void put() {
for(int i = length - 1; i >= 0; --i) printf("%d", buf[i]);
printf("\n");
}
void set(unsigned long long value) {
length = 0;
while(value) {
buf[length++] = value % 10;
value /= 10;
}
}
void add(BigInteger &rhs) {
int upper = 0;
int i = 0;
int digit = 0;
while(i < this->length || i < rhs.length || upper) {
digit = this->buf[i] + rhs.buf[i] + upper;
if(digit >= 10) {
digit -= 10;
upper = 1;
}
else {
upper = 0;
}
this->buf[i] = digit;
i++;
if(i >= length) length = i;
}
}
};
int n, m;
BigInteger dp[101][101];
int main() {
scanf("%d%d", &n, &m);
for(int i = 0; i <= n; ++i) dp[i][0].set(1);
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
dp[i][j].add(dp[i-1][j-1]);
dp[i][j].add(dp[i-1][j]);
}
}
dp[n][m].put();
return 0;
}