「BZOJ3028」食物-生成函数

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 (1x)4x=x(1+x+x2+x3+...)4

考虑组合意义,第 n n n项的答案为在 4 4 4种物品中选若干个组成 n − 1 n-1 n1个物品的方案数。答案为 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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值