//In His Name
#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")
using namespace std;
#define ll long long
#define int ll
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
const int maxn = 5e5 + 10, MOD = 1e9 + 7;
const ll INF = 1e18 + 100;
int n , r ,q , fact[maxn];
vector<int> adj[maxn];
ll Power(ll x , ll y){
if(y < 0 or x < 0) return 0;
if(y == 0) return 1;
ll tmp = Power(x , y/2);
tmp = 1ll * tmp * tmp % MOD;
if(y&1) tmp = 1ll * x * tmp % MOD;
return tmp % MOD;
}
ll tarkib(int x , int y){
if(x == 0 or x == y) return 1;
if(x > y) return 0;
ll zir = fact[x] * fact[y-x] % MOD;
ll res = 1ll * fact[y] * Power(zir , MOD-2);
return res%MOD;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0) , cout.tie(0);
fact[0] = 1;
for(int i = 1 ; i < maxn ; i++) fact[i] = (fact[i-1]*i) % MOD;
cin >> n >> r;
for(int i = 1 ; i <= n-1 ; i++){
int u , v;
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
cin >> q;
cout << tarkib(n-1 , r+n-1) << '\n';
//for(int i = 1 ; i <= q ;i++ ) cout << 1 << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
23380 KB |
Output is correct |
2 |
Correct |
62 ms |
25872 KB |
Output is correct |
3 |
Correct |
61 ms |
25688 KB |
Output is correct |
4 |
Correct |
65 ms |
25860 KB |
Output is correct |
5 |
Correct |
57 ms |
24880 KB |
Output is correct |
6 |
Correct |
8 ms |
16216 KB |
Output is correct |
7 |
Correct |
8 ms |
16220 KB |
Output is correct |
8 |
Correct |
7 ms |
16220 KB |
Output is correct |
9 |
Correct |
76 ms |
25756 KB |
Output is correct |
10 |
Correct |
60 ms |
25940 KB |
Output is correct |
11 |
Correct |
72 ms |
25988 KB |
Output is correct |
12 |
Correct |
64 ms |
25424 KB |
Output is correct |
13 |
Correct |
59 ms |
24660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
15964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
23632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
23488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
23380 KB |
Output is correct |
2 |
Correct |
62 ms |
25872 KB |
Output is correct |
3 |
Correct |
61 ms |
25688 KB |
Output is correct |
4 |
Correct |
65 ms |
25860 KB |
Output is correct |
5 |
Correct |
57 ms |
24880 KB |
Output is correct |
6 |
Correct |
8 ms |
16216 KB |
Output is correct |
7 |
Correct |
8 ms |
16220 KB |
Output is correct |
8 |
Correct |
7 ms |
16220 KB |
Output is correct |
9 |
Correct |
76 ms |
25756 KB |
Output is correct |
10 |
Correct |
60 ms |
25940 KB |
Output is correct |
11 |
Correct |
72 ms |
25988 KB |
Output is correct |
12 |
Correct |
64 ms |
25424 KB |
Output is correct |
13 |
Correct |
59 ms |
24660 KB |
Output is correct |
14 |
Incorrect |
7 ms |
15964 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |