Description
Solution
构造出八种食物的生成函数。
相乘结果为 x ( 1 − x ) 4 = x ( 1 + x + x 2 + x 3 + . . . ) 4 \frac {x} {(1-x)^4}=x(1+x+x^2+x^3+...)^4 (1−x)4x=x(1+x+x2+x3+...)4
考虑组合意义,第 n n n项的答案为在 4 4 4种物品中选若干个组成 n − 1 n-1 n−1个物品的方案数。答案为 C n + 2 3 C_{n+2}^3 Cn+23
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int mod = 10007;
int n;
inline int gi()
{
char c = getchar();
while (c < '0' || c > '9') c = getchar();
int sum = 0;
while ('0' <= c && c <= '9') sum = (sum * 10 + c - 48) % mod, c = getchar();
return sum;
}
int main()
{
freopen("food.in", "r", stdin);
freopen("food.out", "w", stdout);
n = gi() + 2;
printf("%lld\n", (lint)n * (n - 1) / 2 * (n - 2) / 3 % mod);
return 0;
}