Submission #470135

# Submission time Handle Problem Language Result Execution time Memory
470135 2021-09-03T05:25:18 Z Sohsoh84 LOSTIKS (INOI20_lostiks) C++14
0 / 100
186 ms 39412 KB
// orz
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)                      (x).begin(),(x).end()
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << ": " <<  x << endl;

const ll MAXN = 1e6 + 10;
const ll MOD = 1e9 + 7;

inline ll poww(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}

	return ans;
}

int n, r, q;
ll fact[MAXN], inv[MAXN];
vector<int> adj[MAXN];

inline ll C(ll k, ll n) {
	if (k < 0 || k > n) return 0;
	return fact[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fact[0] = inv[0] = 1;
	for (int i = 1; i < MAXN; i++) 
		fact[i] = fact[i - 1] * i % MOD, inv[i] = poww(fact[i], MOD - 2);

	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);	
	}

	cout << C(n - 1, r + n - 1) << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 181 ms 39412 KB Output is correct
2 Incorrect 174 ms 39412 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 186 ms 39364 KB Output is correct
2 Incorrect 178 ms 39340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 181 ms 39412 KB Output is correct
2 Incorrect 174 ms 39412 KB Output isn't correct
3 Halted 0 ms 0 KB -