题解:P10780 BZOJ3028 食物
组合题、个数、累和……能想到生成函数。
仔细看一下,发现这题的生成函数很模版,可以依次求生成函数,再累乘。
承德汉堡:
同理,鸡腿:
鸡块:
蜜桃多:
面包:
所以总的也就是:
现在要取
由插板法,可以得知答案为
代码如下:
/*胡金梁*/
#include<bits/stdc++.h>
using namespace std;
#define __MY_TEST__ 0
const int mod=1e4+7;
int ksm(int a,int b)
{
int re=1;
while(b)
{
if(b&1)
{
re*=a;
re%=mod;
}
a*=a;
a%=mod;
b/=2;
}
return re;
}
signed main(){
#if __MY_TEST__
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n=0;
char ch;
while(cin>>ch)
{
n=(n*10+ch-'0')%mod;
}
cout<<n*(n+1)%mod*(n+2)%mod*ksm(6,mod-2)%mod;
#if __MY_TEST__
fclose(stdin);
fclose(stdout);
#endif
}