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;
}
本文探讨了通过组合八种食物来构成特定数量食品的数学问题。利用组合数学原理,文章详细阐述了如何通过生成函数求解特定组合的方案数,并提供了一段C++代码实现。核心在于理解组合意义及应用多项式展开。
1771

被折叠的 条评论
为什么被折叠?



