【题解】JSOI2011分特产
没sa可suo的,sui题一道……
#include <bits/stdc++.h>
using namespace std;
#define maxn 3000
#define mod 1000000007
#define int long long
int n, m, ans, a[maxn], C[maxn][maxn]; int read()
{
int x = , k = ;
char c; c = getchar();
while(c < '' || c > '') { if(c == '-') k = -; c = getchar(); }
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * k;
} void Pre()
{
for(int i = ; i < maxn; i ++) C[i][] = ;
for(int i = ; i < maxn; i ++)
for(int j = ; j < maxn; j ++)
C[i][j] = (C[i - ][j - ] + C[i - ][j]) % mod;
} int Up(int &x, int y) { x = (x + y) % mod; }
int Get(int x)
{
int ret = ;
for(int i = ; i <= m; i ++)
ret = ret * C[n - x + a[i] - ][n - x - ] % mod;
return ret;
} signed main()
{
n = read(), m = read(); Pre();
for(int i = ; i <= m; i ++) a[i] = read();
for(int i = ; i <= n; i ++)
{
int t = C[n][i] * Get(i) % mod;
Up(ans, (i & ) ? -t : t);
}
printf("%lld\n", (ans + mod) % mod);
return ;
}
【题解】JSOI2011分特产的更多相关文章
- 题解-JSOI2011 分特产
题面 JSOI2011 分特产 有 \(n\) 个不同的盒子和 \(m\) 种不同的球,第 \(i\) 种球有 \(a_i\) 个,用光所有球,求使每个盒子不空的方案数. 数据范围:\(1\le n, ...
- 【BZOJ4710】[Jsoi2011]分特产 组合数+容斥
[BZOJ4710][Jsoi2011]分特产 Description JYY 带队参加了若干场ACM/ICPC 比赛,带回了许多土特产,要分给实验室的同学们. JYY 想知道,把这些特产分给N 个同 ...
- BZOJ 4710: [Jsoi2011]分特产 [容斥原理]
4710: [Jsoi2011]分特产 题意:m种物品分给n个同学,每个同学至少有一个物品,求方案数 对于每种物品是独立的,就是分成n组可以为空,然后可以用乘法原理合起来 容斥容斥 \[ 每个同学至少 ...
- bzoj4710: [Jsoi2011]分特产 组合+容斥
4710: [Jsoi2011]分特产 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 289 Solved: 198[Submit][Status] ...
- bzoj4710 [Jsoi2011]分特产(容斥)
4710: [Jsoi2011]分特产 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 814 Solved: 527[Submit][Status] ...
- 4710: [Jsoi2011]分特产
4710: [Jsoi2011]分特产 链接 分析: 容斥原理+隔板法. 代码: #include<cstdio> #include<algorithm> #include&l ...
- 【BZOJ 4710】 4710: [Jsoi2011]分特产 (容斥原理)
4710: [Jsoi2011]分特产 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 99 Solved: 65 Description JYY 带 ...
- [BZOJ4710][JSOI2011]分特产(组合数+容斥原理)
4710: [Jsoi2011]分特产 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 395 Solved: 262[Submit][Status] ...
- BZOJ 4710 [Jsoi2011]分特产 解题报告
4710 [Jsoi2011]分特产 题意 给定\(n\)个集合,每个集合有相同的\(a_i\)个元素,不同的集合的元素不同.将所有的元素分给\(m\)个不同位置,要求每个位置至少有一个元素,求分配方 ...
- ●BZOJ 4710 [Jsoi2011]分特产
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=4710 题解: 容斥,组合先看看这个方案数的计算:把 M 个相同的东西分给 N 个人,每个人可 ...
随机推荐
- 非Contorller类使用@Service中的方法
组件扫描这种的是指bean,跟service没关系 service只能在Controller类中使用,如果别的类想使用,必须使用下面这种方法 内容来源:https://blog.csdn.net/u0 ...
- hive bug
SHELL$ hive -S -e “set” | grep warehouse hive.metastore.warehouse.dir=/user/hive/warehouse hive.ware ...
- RyuBook1.0案例一:Switching Hub项目源码分析
开发目标 实现一个带MAC地址学习功能的二层交换机 Openflow交换机与Openflow控制器安全通道建立步骤 switch and controller建立未加密TCP连接或者加密的TLS连接 ...
- 简单在kubernetes中安装cadvisor
cadvisor用于分析docker资源占用情况及性能的工具 安装命令: docker run --volume=/:/rootfs:ro --volume=/: --detach=true --na ...
- 从零开始的Python学习Episode 13——常用模块
模块 一.time模块 时间戳(timestamp) :时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量. 元组(struct_time) :struct_time元组共有9 ...
- Blockchain For Dummies(IBM Limited Edition
Blockchain For Dummies(IBM Limited Edition)笔记 该系列内容主要介绍用于商业的区块链,有人说区块链之于贸易,犹如因特网之于信息.在商业领域区块链可以用于交易任 ...
- 如何成为优秀评级卖家(Top-rated seller)?与超级卖家的区别是
以eBay美国站点为例,要成为优秀评级卖家(Top-rated seller),需满足如下条件: ● 先成为 eBay超级卖家 ● Low DSR (US buyers) <= 0.50% 或 ...
- 亚马逊:PS4和Xbox One实在太火
圣诞节刚刚结束,当实体零售商在抱怨坑爹的天气让自己节日生意变得冷清的同时,在线零售商们却依旧赚的盆满钵满. 亚马逊近日表示,今年节日期间的零售工作非常不错,新一代游戏机更是最大的亮点.据销售统计,在圣 ...
- [linux] reboot和shutdown-r的区别
google看看: 先搜英文的资料 http://askubuntu.com/questions/441969/what-is-the-difference-between-reboot-and-sh ...
- [C++] Solve "Cannot run program "gdb": Unknown reason" error
In Mac OSX, The Issue Image: 1. Build the project on Eclipse successfully. 2. Run gdb on command lin ...