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 ...
随机推荐
- ios Instruments 内存泄露
本文转载至 http://my.oschina.net/sunqichao/blog?disp=2&p=3 虽然iOS 5.0版本之后加入了ARC机制,由于相互引用关系比较复杂时,内存泄露还是 ...
- iOS性能调优系列(全)
总结: 三类工具 基础工具 (NSLog的方式记录运行时间.) 性能工具.检测各个部分的性能表现,找出性能瓶颈 内存工具.检查内存正确性和内存使用效率 性能工具: 可以衡量CPU的使用,时间的消耗,电 ...
- HTML5中新的结构元素
HTML5中新的结构元素 1. HTML5初始文件 1.1.doctype 在之前,doctype的声明是这样的: "http://www.w3. org/TR/html4/strict.d ...
- mouseover&mouseout和mouseenter&mouseleave
mouseenter&mouseleave: 进入被选元素触发,进入被选元素的子元素不会重复触发. mouseover&mouseout: 进入被选元素触发,从被选元素进入其子元素会再 ...
- Eclipse '<>' operator is not allowed for source level below 1.7
'<>' operator is not allowed for source level below 1.7 解决方法:
- nohop以及后台运行的相关集合
本文参考:https://blog.csdn.net/u011095110/article/details/78666833 1. 后台运行一个命令: & tar -czvf /mnt/aa. ...
- 【BZOJ3727】PA2014 Final Zadanie 树形DP
[BZOJ3727]PA2014 Final Zadanie Description 吉丽YY了一道神题,题面是这样的:“一棵n个点的树,每条边长度为1,第i个结点居住着a[i]个人.假设在i结点举行 ...
- Ubuntu 16.04 安装和配置 Redis
因为发现之前手动安装的 redis 与现有的教程不一样,所以总结统一一下安装的标准步骤. 安装依赖项 为了获取最新版本的 Redis,我们将从源代码进行编译和安装.下载源代码之前,需要先安装一些编译所 ...
- 170524、java.lang.IllegalArgumentException: No converter found for return value of type异常解决
错误原因及解决步骤 1.原因:这是因为springmvc默认是没有对象转换成json的转换器的,需要手动添加jackson依赖. 2.解决步骤: 手动添加jackson依赖到pom.xml文件中 &l ...
- Drools规则引擎
一.简介 Drools is a Business Rules Management System (BRMS) solution. It provides a core Business Rules ...