#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define err(x) cerr<<#x<<"="<<x<<'\n'
#define lc 2*id
#define rc 2*id+1
#define dmid int mid=(r+l)/2
#define all(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define pb push_back
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define bit(i,j) ((j>>i)&1)
using namespace std;
const int md=1e9+7;
const int N=5e5+4;
int fct[N],inv[N];
int pw(int a,int b){
int rt=1;
while(b){
if(b&1) rt=1LL*rt*a%md;
a=1LL*a*a%md;
b/=2;
}
return rt;
}
int C(int r,int n){
return (1LL*(1LL*fct[n]*inv[r]%md)*inv[n-r]%md);
}
int32_t main(){
iostream::sync_with_stdio(0); cin.tie(0);
fct[0]=1; FOR(i,1,N-1) fct[i]=1LL*fct[i-1]*i%md;
inv[N-1]=pw(fct[N-1],md-2); FORR(i,N-2,0) inv[i]=1LL*inv[i+1]*(i+1)%md;
int n,r; cin>>n>>r;
FOR(i,1,n-1){
int u,v; cin>>u>>v;
}
int q; cin>>q;
assert(q==0);
cout<<C(n-1,n-1+r)<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
6628 KB |
Output is correct |
2 |
Correct |
40 ms |
6632 KB |
Output is correct |
3 |
Correct |
42 ms |
6632 KB |
Output is correct |
4 |
Correct |
40 ms |
6640 KB |
Output is correct |
5 |
Correct |
45 ms |
6628 KB |
Output is correct |
6 |
Correct |
10 ms |
4180 KB |
Output is correct |
7 |
Correct |
10 ms |
4248 KB |
Output is correct |
8 |
Correct |
10 ms |
4152 KB |
Output is correct |
9 |
Correct |
40 ms |
6632 KB |
Output is correct |
10 |
Correct |
41 ms |
6528 KB |
Output is correct |
11 |
Correct |
51 ms |
6636 KB |
Output is correct |
12 |
Correct |
38 ms |
6388 KB |
Output is correct |
13 |
Correct |
38 ms |
6372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
8336 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
49 ms |
10868 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
49 ms |
10984 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
6628 KB |
Output is correct |
2 |
Correct |
40 ms |
6632 KB |
Output is correct |
3 |
Correct |
42 ms |
6632 KB |
Output is correct |
4 |
Correct |
40 ms |
6640 KB |
Output is correct |
5 |
Correct |
45 ms |
6628 KB |
Output is correct |
6 |
Correct |
10 ms |
4180 KB |
Output is correct |
7 |
Correct |
10 ms |
4248 KB |
Output is correct |
8 |
Correct |
10 ms |
4152 KB |
Output is correct |
9 |
Correct |
40 ms |
6632 KB |
Output is correct |
10 |
Correct |
41 ms |
6528 KB |
Output is correct |
11 |
Correct |
51 ms |
6636 KB |
Output is correct |
12 |
Correct |
38 ms |
6388 KB |
Output is correct |
13 |
Correct |
38 ms |
6372 KB |
Output is correct |
14 |
Runtime error |
12 ms |
8336 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |