-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9184.cpp
More file actions
43 lines (34 loc) · 935 Bytes
/
9184.cpp
File metadata and controls
43 lines (34 loc) · 935 Bytes
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
#include <iostream>
#define N 55
using namespace std;
int a, b, c;
long long d[N*3][N*3][N*3];
long long get(int x, int y, int z)
{
int xx, yy, zz;
xx = x+N;
yy = y+N;
zz = z+N;
if (d[xx][yy][zz]!=0)
return d[xx][yy][zz];
if (x <= 0 || y <= 0 || z <= 0)
return d[xx][yy][zz] = 1;
if (x > 20 || y > 20 || z > 20)
return d[xx][yy][zz] = get(20, 20, 20);
if (x < y && y < z)
return d[xx][yy][zz] = get(x, y, z - 1) + get(x, y - 1, z - 1) - get(x, y - 1, z);
return d[xx][yy][zz] = get(x - 1, y, z) + get(x - 1, y - 1, z) + get(x - 1, y, z - 1) - get(x - 1, y - 1, z - 1);
}
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
while (1)
{
cin >> a >> b >> c;
if (a == -1 && b == -1 && c == -1)
break;
printf("w(%d, %d, %d) = %lld\n", a, b, c, get(a, b, c));
}
return 0;
}