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;
const long long mod = 1e9+7;
const int N = 5e5+10;
long long fact[N];
long long binpow(long long a, long long b) {
long long ans = 1;
while(b) {
if(b&1) {
ans=(ans*a)%mod;
}
a=(a*a)%mod;
b>>=1;
}
return ans;
}
long long ncr(long long nn, long long rr) {
if(rr > nn)return 0;
long long ans = fact[nn];
ans = (ans*binpow(fact[rr], mod-2))%mod;
ans = (ans*binpow(fact[nn-rr], mod-2))%mod;
return ans;
}
int main () {
cin.tie(0)->sync_with_stdio(0);
fact[0] = 1;
for(int i = 1;i<N;i++)fact[i] = (fact[i-1]*i)%mod;
int n, r;
cin >> n >> r;
int q;
while(cin >> q);
cout << ncr(n+r-1, r) << "\n";
}
# | 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... |