bzoj1630 / bzoj2023 [Usaco2005 Nov]Ant Counting 数蚂蚁
Description
Input
Output
Sample Input
1
2
2
1
3
INPUT DETAILS:
Three types of ants (1..3); 5 ants altogether. How many sets of size 2 or
size 3 can be made?
Sample Output
OUTPUT DETAILS:
5 sets of ants with two members; 5 more sets of ants with three members
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#define re register
using namespace std;
void read(int &x){
char c=getchar();x=;
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=(x<<)+(x<<)+(c^),c=getchar();
}
int min(int a,int b){return a<b?a:b;}
#define p 1000000
int t,a,s,b,q,f[],d[],sum[],ans;
int main(){
read(t);read(a);read(s);read(b); f[]=sum[]=;
for(re int i=;i<=a;++i) read(q),++d[q];
for(re int i=;i<=t;++i){
for(re int j=;j<=b;++j) sum[j]=(sum[j-]+f[j])%p;//前缀和处理
for(re int j=b;j>=;--j){
if(j<=d[i]) f[j]=sum[j]%p;//注意边界
else f[j]=(sum[j]-sum[j-d[i]-])%p;
}
}
for(re int i=s;i<=b;++i) ans=(ans+f[i])%p;
printf("%d",ans);
return ;
}
bzoj1630 / bzoj2023 [Usaco2005 Nov]Ant Counting 数蚂蚁的更多相关文章
- bzoj2023[Usaco2005 Nov]Ant Counting 数蚂蚁*&&bzoj1630[Usaco2007 Demo]Ant Counting*
bzoj2023[Usaco2005 Nov]Ant Counting 数蚂蚁&&bzoj1630[Usaco2007 Demo]Ant Counting 题意: t个族群,每个族群有 ...
- BZOJ2023: [Usaco2005 Nov]Ant Counting 数蚂蚁
2023: [Usaco2005 Nov]Ant Counting 数蚂蚁 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 56 Solved: 16[S ...
- BZOJ2023: [Usaco2005 Nov]Ant Counting 数蚂蚁(dp)
题意 题目描述的很清楚... 有一天,贝茜无聊地坐在蚂蚁洞前看蚂蚁们进进出出地搬运食物.很快贝茜发现有些蚂蚁长得几乎一模一样,于是她认为那些蚂蚁是兄弟,也就是说它们是同一个家族里的成员.她也发现整个 ...
- 1630/2023: [Usaco2005 Nov]Ant Counting 数蚂蚁
2023: [Usaco2005 Nov]Ant Counting 数蚂蚁 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 85 Solved: 40[S ...
- 【bzoj2023/1630】[Usaco2005 Nov]Ant Counting 数蚂蚁 dp
题解: 水题 f[i][j] 前i种用了j个,前缀和优化就可以了
- BZOJ 2023 [Usaco2005 Nov]Ant Counting 数蚂蚁:dp【前缀和优化】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2023 题意: 有n个家族,共m只蚂蚁(n <= 1000, m <= 1000 ...
- bzoj 2023: [Usaco2005 Nov]Ant Counting 数蚂蚁【生成函数||dp】
用生成函数套路推一推,推完老想NTT--实际上把这个多项式乘法看成dp然后前缀和优化一下即可 #include<iostream> #include<cstdio> using ...
- 【noi 2.6_9289】Ant Counting 数蚂蚁{Usaco2005 Nov}(DP)
题意:有M个家族的蚂蚁,各Ni只(互相相同).问选出 l~r 只的不同方案数. 解法:很基础的一种DP,不要被"排列组合"所迷惑了啊~我之前接触过这个类型,可惜又忘了,一定要记住! ...
- [poj3046][Ant counting数蚂蚁]
题目链接 http://noi.openjudge.cn/ch0206/9289/ 描述 Bessie was poking around the ant hill one day watching ...
随机推荐
- 判断页面中的js方法是否存在,存在就调用它,不存在则忽略
if(typeof queryResource != 'undefined' && queryResource instanceof Function) queryResource(a ...
- JS时间格式化函数
Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month & ...
- const关键字浅析
1 const变量 const double PI = 3.14159; 定义之后不能被修改,所以定义时必须初始化. const int i, j = 0; // error: i is unini ...
- Android Framewrork资源类型有哪些?
1. Google Framework res frameworks/base/core/res/res/values <public type="attr" name=&q ...
- vux报错二
执行npm run build后 "build": "node build/build.js", // 输出提示信息 - 提示用户请在 http 服务下查看 ...
- linux 下 安装go
首先肯定是下载资源包了,链接汇总在http://www.golangtc.com/download,我用的是 http://www.golangtc.com/static/go/go1.4beta1. ...
- Android - XML序列化
1.xml文件的序列化:采用XmlSerializer来实现XML文件的序列化.相比传统方式,更高效安全 MainActivity.java package com.example.test_buil ...
- PHP概率算法---砸金蛋示例
这是一个很经典的概率算法: function get_rand($proArr) { $result = ''; //概率数组的总概率精度 $proSum = array_sum($proArr); ...
- 170622、springboot编程之JPA操作数据库
JPA操作数据库 什么事JAP?JPA全称Java Persistence API.JPA通过JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中. 1.在pom ...
- 使用webmagic搭建一个简单的爬虫
刚刚接触爬虫,听说webmagic很不错,于是就了解了一下. webmagic的是一个无须配置.便于二次开发的爬虫框架,它提供简单灵活的API,只需少量代码即可实现一个爬虫. 这句话说的真的一点都不假 ...