Source: Light OJ 1102 problem makes problem
Test instructions: An integer n is decomposed into the number of K to add how many scheme numbers can be duplicated
Idea: M apples put n boxes how many schemes allow boxes empty boxes Null correspondence 0 answer is C (n+m-1, n-1)
First of all, if the answer is not allowed is C (m-1, n-1) intervening spaces m Apple has a m-1 gap in this m-1 neutral selection n-1 a divided into n parts each part is not empty
Now allowed to empty then add an apple to each box is equivalent to n+m an Apple into n parts n+m-1 a neutral n-1 C (n+m-1, n-1)
Each part is at least 1 to 1 is actually empty I started adding it to facilitate the use of the intervening spaces method
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long LL;
Const LL mod = 1000000007;
const int MAXN = 2000010;
return a^p mod n fast power
LL A[MAXN];
ll Pow_mod (ll A, ll P, ll N)
{
ll ans = 1;
while (p)
{
if (p&1)
{
ans *= A;
Ans%= n;
}
A *= A;
a%= n;
P >>= 1;
}
return ans;
}
ll C (ll N, ll m)
{
ll x = a[n], y = a[n-m]*a[m]%mod;
return X*pow_mod (y, mod-2, MoD)%mod;
}
int main ()
{
a[0] = 1;
for (int i = 1; I <= 2000000; i++)
{
a[i] = a[i-1]*i;
A[i]%= mod;
}
int cas = 0;
int T;
scanf ("%d", &t);
while (t--)
{
LL n, m;
scanf ("%lld%lld", &n, &m);
printf ("Case%d:%lld\n", ++cas, C (n+m-1, m-1));
}
return 0;
}