版权声明:随意转载哦......但还是请注明出处吧: https://blog.csdn.net/dreaming__ldx/article/details/85398010
传送门
生成函数模板题。
我们直接把每种食物的生成函数列出来:
承德汉堡:
1+x2+x4+...=1−x21
可乐:
1+x=1−x1−x2
鸡腿:
1+x+x2=1−x1−x3
蜜桃多:
x+x3+x5+...=x(1+x2+x4+...)=1−x2x
鸡块:
1+x4+x8+x12+...=1−x41
包子:
1+x+x2+x3=1−x1−x4
土豆片炒肉:
1+x=1−x1−x2
面 包:
1+x3+x6+x9+...=1−x31
把所有的乘起来:
f(x)=(1−x)4x=x(1+x+x2+...)4
我们要求
xn的系数。
也就是求
g(x)=(1+x+x2+...)4的
xn−1的系数。
相当于求将
n−1拆成四个自然数的方案数,这个组合数学搞定
Ans=Cn+23
代码:
#include<bits/stdc++.h>
using namespace std;
const int mod=10007;
int n=0;
int main(){
char ch=getchar();
while(!isdigit(ch))ch=getchar();
while(isdigit(ch))n=((n<<3)+(n<<1)+(ch^48))%mod,ch=getchar();
cout<<n*(n+1)%mod*(n+2)%mod*1668%mod;
return 0;
}