You are viewing a single comment's thread. Return to all comments →
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
ll fact[2001];
ll factorial(ll n) {
if(n<=1) fact[n]=1; if(fact[n]==0) fact[n]=(factorial(n-1)*n)%mod; return fact[n];
}
ll power(ll a,ll b) {
ll res=1; while(b){ if(b%2) res=(res*a)%mod; a=(a*a)%mod; b/=2; } return res;
} int main() {
ll t; cin>>t; while(t--){ ll n,m; cin>>n>>m; cout<<(factorial(n+m-1)*power(factorial(n),mod- 2)%mod*power(factorial(m-1),mod-2) %mod)%mod<<endl; }
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
include
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
ll fact[2001];
ll factorial(ll n) {
}
ll power(ll a,ll b) {
} int main() {
}