solution-code4763

每种食物的生成函数

汉堡: 1+x2+x4+⋯=11−x2

可乐: 1+x=1−x21−x

鸡腿: 1+x+x2=1−x31−x

蜜桃多: x+x3+x5+⋯=x1−x2

鸡块: 1+x4+x8+⋯=11−x4

包子: 1+x+x2+x3=1−x41−x

土豆片炒肉: 1+x=1−x21−x

面包: 1+x3+x6+⋯=11−x3

乘在一起得到: f(x)=x(1−x)4=x⋅(1−x)−4

带入广义二项式定理得 f(x)=x⋅∑i=0∞Ci+3i⋅xi

当 i=n−1 时第 n−1 项为 x⋅Cn+2n⋅xn=Cn+23⋅xn

所以答案就为 ans=n(n+1)(n+2)6

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define mod 10007
#define inv6 1668
using namespace std;
inline int GetInt()
{
int ch,num=0;
while(ch=getchar())
{
if(ch>='0'&&ch<='9')break;
}
while(ch>='0'&&ch<='9')
{
num=(num*10+ch-'0')%mod;
ch=getchar();
}
return num;
}
int main(void)
{
int n=GetInt();
printf("%d\n",n*(n+1)%mod*(n+2)%mod*inv6%mod);
return 0;
}