#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MXN = 3e5 + 5;
const int mod = 1e9 + 7;
int n, r;
vector<int> adj[MXN];
int f[MXN];
int pw(int a, int b, int c)
{
a %= c;
int res = 1;
while (b)
{
if (b & 1) res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
int nck(int n, int k)
{
if (min(n, k) < 0 || k > n) return 0;
return (f[n] * pw((f[n - k] * f[k]) % mod, mod - 2, mod)) % mod;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
f[0] = 1;
for (int i = 1; i < MXN; i++) f[i] = (f[i - 1] * i) % mod;
cin >> n >> r;
for (int i = 1; i < n; i++)
{
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
int q, res = 0;
cin >> q;
cout << nck(n + r - 1, r) << '\n';
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:47:9: warning: unused variable 'res' [-Wunused-variable]
47 | int q, res = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
19540 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
9816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
47 ms |
19520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
50 ms |
19792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
19540 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |