This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=5e5+5,M=1e9+7;
int n,q,r;
ll fuck[mxn],rfuck[mxn];
ll ferma(ll x){
ll res=1,num=M-2;
while(num){
if(num&1)res=(res*x)%M;
x=(x*x)%M;
num/=2;
}
return res;
}
ll comb(ll x,ll y){
return (((fuck[y]*rfuck[x])%M)*rfuck[y-x])%M;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>r;
fuck[0]=1;
for(int i=1;i<mxn;i++){
fuck[i]=(fuck[i-1]*i)%M;
rfuck[i]=ferma(fuck[i]);
}
for(int i=1;i<=n-1;i++){
int x,y;
cin>>x>>y;
//v[x].push_back(y);
//v[y].push_back(x);
}
cout<<comb(n-1,n+r-1);
cin>>q;
while(q--){
}
return 0;
}
# | 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... |