| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1292952 | BuiDucManh123 | Sumtree (INOI20_sumtree) | C++20 | 55 ms | 17144 KiB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define taskname ""
const int mod = 1e9+7;
using namespace std;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#define int ll
const int N = 3e5;
int gt[N + 5], fgt[N + 5];
ll mu(ll a, ll b){
ll res = 1;
while(b){
if(b & 1){
res = res * a % mod;
}
a = a * a % mod;
b >>= 1;
}
return res;
}
ll C(ll n, ll k){
if(k < 0 || k > n) return 0;
return gt[n] * fgt[n - k] % mod * fgt[k] % mod;
}
vector<int> g[N + 5];
void solve(){
gt[0] = 1;
for(int i = 1; i <= N; i++){
gt[i] = gt[i - 1] * i % mod;
}
fgt[N] = mu(gt[N], mod - 2);
for(int i = N - 1; i >= 0; i--){
fgt[i] = fgt[i + 1] * (i + 1) % mod;
}
int n, r;
cin >> n >> r;
for(int i = 1; i < n; i++){
int u, v;
cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
int q;
cin >> q;
cout << C(n + r - 1, n - 1);
}
signed main() {
if (fopen(taskname".inp","r")) {
freopen(taskname".inp","r",stdin);
freopen(taskname".out","w",stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int test = 1;
//cin >> test;
while(test--){
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
