-
Notifications
You must be signed in to change notification settings - Fork 0
/
232B.cpp
74 lines (64 loc) · 1.22 KB
/
232B.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
64
65
66
67
68
69
70
71
72
73
74
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
const int nmax = 101;
const int MOD = 1000000007;
int dp[nmax][nmax * nmax];
int C[nmax][nmax];
int powC[nmax][2];
int modpow(int x, long long p)
{
if (p == 0)
return 1;
if (p == 1)
return x;
long long X = modpow(x, p / 2);
X = (X * X) % MOD;
if (p & 1)
X = X * x % MOD;
return X;
}
int main()
{
int n, i, j, k, s;
long long m;
cin >> n >> m >> s;
for (i = 0; i <= n; i++)
{
C[i][0] = 1;
for (j = 1; j <= i; j++)
C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
}
for (i = 0; i <= n; i++)
{
powC[i][0] = modpow(C[n][i], m / n);
powC[i][1] = powC[i][0] * 1LL * C[n][i] % MOD;
}
dp[0][0] = 1;
for (i = 0; i < n; i++)
for (j = 0; j <= s; j++)
{
if (dp[i][j] == 0) continue;
for (k = 0; k <= n && j + k <= s; k++)
dp[i + 1][j + k] = (dp[i + 1][j + k] + 1LL * dp[i][j] * powC[k][m % n > i]) % MOD;
}
cout << dp[n][s] << endl;
return 0;
}