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 ...
随机推荐
- 解决 ssh 登录到ubuntu server 慢的问题
最近在服务器上使用ubuntu系统,服务器上开启sshd服务,在客户端处使用ssh登录到服务器的时候出现卡顿的现象. 在网上搜索了解决方案,主要是: 1. 修改服务器的 /etc/ssh/sshd_c ...
- 学习C++服务端一:MySql与C++
mysql学习: http://www.cnblogs.com/cy163/archive/2008/10/16/1312277.html http://developer.51cto.com/art ...
- vue报错一
8080端口被占用 解决方案: 打开cmd输入:netstat -ano查看所有端口信息,如图,找到端口 8080,以及对应的 PID: 输入:tskill PID 即可杀死进程,ex:: tskil ...
- Mysql explain执行计划
EXPLAIN(小写explain)显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. EXPLAIN + sql语句可以查看mysql的执行 ...
- 【BZOJ3003】LED BFS+状压DP
[BZOJ3003]LED Description LED屏是由一个庞大的点阵小灯泡组成的,一开始每个小灯泡都不发光.每一行一共有N个小灯泡,依次标号为1~n.现在给定K个点,要求这K个点发光,其余点 ...
- onethink封装arclist调用文章列表!
其实没有什么东西,做个记录,方便以后使用! <ul> <arclist mid='2' cid='2' row='2'> <li>{$title}</li&g ...
- 三维凸包求内部一点到表面的最近距离(HDU4266)
http://acm.hdu.edu.cn/showproblem.php?pid=4266 The Worm in the Apple Time Limit: 50000/20000 MS (Jav ...
- vue自定义过滤器的创建和使用
1.简单介绍 过滤器的作用:实现数据的筛选.过滤.格式化. 过滤器的本质是一个有参数,有返回值的方法. 过滤器可以用在两个地方:双花括号插值和v-bind表达式(后者从2.1.0+开始支持 ...
- CH1809匹配统计【KMP】
1809 匹配统计 0x18「基本数据结构」练习 描述 阿轩在纸上写了两个字符串,分别记为A和B.利用在数据结构与算法课上学到的知识,他很容易地求出了“字符串A从任意位置开始的后缀子串”与“字符串B” ...
- proxy,https,git,tortoise git,ssh-agent,ssh-add,ssh,ssl,rsync
看具体应用了,一般的文件复制使用scp,增量同步使用rsync.rsync的认证可以使用ssh,还可以是rsync自己的密码文件. ssh-keygen -l 察看 fineprint 5.1 通过p ...