-
Notifications
You must be signed in to change notification settings - Fork 1
/
20_October.cpp
48 lines (47 loc) · 1.68 KB
/
20_October.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
class Solution
{
public:
int getSum(int x, int y, int z)
{
int mod = (int)(1e9 + 7);
long long exactsum[x + 1][y + 1][z + 1];
long long exactnum[x + 1][y + 1][z + 1];
memset(exactnum, 0, sizeof exactnum);
memset(exactsum, 0, sizeof exactsum);
long long ans = 0;
exactnum[0][0][0] = 1;
for (int i = 0; i <= x; ++i)
{
for (int j = 0; j <= y; ++j)
{
for (int k = 0; k <= z; ++k)
{
if (i > 0)
{
exactsum[i][j][k] += (exactsum[i - 1][j][k] * 10 +
4 * exactnum[i - 1][j][k]) %
mod;
exactnum[i][j][k] += exactnum[i - 1][j][k] % mod;
}
if (j > 0)
{
exactsum[i][j][k] += (exactsum[i][j - 1][k] * 10 +
5 * exactnum[i][j - 1][k]) %
mod;
exactnum[i][j][k] += exactnum[i][j - 1][k] % mod;
}
if (k > 0)
{
exactsum[i][j][k] += (exactsum[i][j][k - 1] * 10 +
6 * exactnum[i][j][k - 1]) %
mod;
exactnum[i][j][k] += exactnum[i][j][k - 1] % mod;
}
ans += exactsum[i][j][k] % mod;
ans %= mod;
}
}
}
return (int)ans;
}
};