Submission #999040

#TimeUsernameProblemLanguageResultExecution timeMemory
999040vjudge1Sumtree (INOI20_sumtree)C++17
10 / 100
63 ms41640 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MXN = 1e6 + 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 (stderr)

Main.cpp: In function 'int main()':
Main.cpp:47:9: warning: unused variable 'res' [-Wunused-variable]
   47 |  int q, res = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...