Submission #632477

#TimeUsernameProblemLanguageResultExecution timeMemory
632477codr0Sumtree (INOI20_sumtree)C++14
10 / 100
51 ms10984 KiB
#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; }
#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...