poj3046
dp,可以再优化。
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int t,a,s,b,tmp;
int x[];
int dp[][];
const int mod = 1e6;
void solve(int res)
{
for(int i = ; i <= x[]; i++)
{
dp[][i] = ;
}
for(int i = ; i < t+; i++)
{
memset(dp[i & ], , sizeof(dp[i & ]));
for(int j = ; j <= res; j++)
{
for(int k = ; k <= x[i] && k <= j; k++)
{
dp[i & ][j] = (dp[i & ][j] + dp[(i-) & ][j-k]) % mod;
}
}
}
} int main()
{
cin >> t >> a >> s >> b;
for(int i = ; i < a; i++)
{
scanf("%d", &tmp);
x[tmp]++;
}
int cnt = ;
solve(a);
for(int i = s; i <= b; i++)
{
cnt = (cnt + dp[t & ][i]) % mod;
}
cout << cnt << endl;
return ;
}
poj3046的更多相关文章
- POJ3046选蚂蚁创建集合_线性DP
POJ3046选蚂蚁创建集合 一个人的精力是有限的呢,如果一直做一件事迟早会疲惫,所以自己要把握好,不要一直埋头于一件事,否则效率低下还浪费时间 题目大意:一共有T(1,2...n为其种类)种蚂蚁,A ...
- [poj3046]Ant Counting(母函数)
题意: S<=x1+x2+...+xT<=B 0<=x1<=N1 0<=x2<=N2 ... 0<=xT<=NT 求这个不等式方程组的解的个数. 分析: ...
- [poj3046][Ant counting数蚂蚁]
题目链接 http://noi.openjudge.cn/ch0206/9289/ 描述 Bessie was poking around the ant hill one day watching ...
- 2019.01.02 poj3046 Ant Counting(生成函数+dp)
传送门 生成函数基础题. 题意:给出nnn个数以及它们的数量,求从所有数中选出i∣i∈[L,R]i|i\in[L,R]i∣i∈[L,R]个数来可能组成的集合的数量. 直接构造生成函数然后乘起来f(x) ...
- poj3046 Ant Counting——多重集组合数
题目:http://poj.org/problem?id=3046 就是多重集组合数(分组背包优化): 从式子角度考虑:(干脆看这篇博客) https://blog.csdn.net/viphong/ ...
- poj-3046 Ant Counting【dp】【母函数】
题目链接:戳这里 题意:有A只蚂蚁,来自T个家族,每个家族有ti只蚂蚁.任取n只蚂蚁(S <= n <= B),求能组成几种集合? 这道题可以用dp或母函数求. 多重集组合数也是由多重背包 ...
- 《挑战程序设计竞赛》2.3 动态规划-优化递推 POJ1742 3046 3181
POJ1742 http://poj.org/problem?id=1742 题意 有n种面额的硬币,面额个数分别为Ai.Ci,求最多能搭配出几种不超过m的金额? 思路 据说这是传说中的男人8题呢,对 ...
- 【POJ - 3046】Ant Counting(多重集组合数)
Ant Counting 直接翻译了 Descriptions 贝西有T种蚂蚁共A只,每种蚂蚁有Ni只,同种蚂蚁不能区分,不同种蚂蚁可以区分,记Sum_i为i只蚂蚁构成不同的集合的方案数,问Sum_k ...
随机推荐
- 点分治 [IOI2011]Race
BZOJ2599. 放板子.利用agc009-D 代码简洁了很多 #include <bits/stdc++.h> #define N 200005 using namespace std ...
- the generation has been cancelled because errors have been found by the check model
生成物理模型出现这个错误的话,那就打开“生成物理模型”(快捷键 ctrl+shift+p) 然后找到 Detail → Option 接着讲Check mode复选框去掉.
- swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter.
'swprintf': swprintf has been changed to conform with the ISO C standard, adding an extra character ...
- float和Float的区别
float是基本数据类型,Float是包装类(封装类).封装类可将接本数据类型封装后当作对象进行操作,并为各种基本数据类型提供各种转换功能.例如Float f = new Float(3.4f);,即 ...
- POJ-3629
Card Stacking Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3927 Accepted: 1541 Des ...
- Flutter实战视频-移动电商-57.购物车_在Model中增加选中字段
57.购物车_在Model中增加选中字段 先修改model类 model/cartInfo.dart类增加是否选中的属性 修改provide 修改UI部分pages/cart_page/cart_it ...
- ASP.NET Core MVC 2.x 全面教程_ASP.NET Core MVC 26. 缓存
In-Memory 使用IMemeryCache接口 注册缓存 HomeController注入进来 建一个类,用来存缓存的常量 判断缓存里面是否有数据,如果没有就读数据库存起来. 设置缓存事件,可调 ...
- myeclipse 去掉spring特性支持
myeclipse10.0 去掉spring支持 手工修改工程目录下的.project文件中相关的内容 删除<nature>com.genuitec.eclipse.springfram ...
- 洛谷 - P1829 - Crash的数字表格 - 莫比乌斯反演
求: \(S(n,m)=\sum\limits_{i=1}^{n}\sum\limits_{j=1}^{m}lcm(i,j)\) 显然: \(S(n,m)=\sum\limits_{i=1}^{n}\ ...
- js对象—类型和属性特性
前言 权威指南中摘要的,工作中用不到的,重要的js基础. 三类对象两类属性 内置对象(native object) 是由ECMScript规范定义的对象或者类.例如:函数,数组,日期,正则... 宿主 ...