BZOJ 1630/2023 Ant Counting 数蚂蚁
DP.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100050
#define mod 1000000
using namespace std;
int n,m,l,r,sum[][maxn],cnt[maxn],x;
int main()
{
scanf("%d%d%d%d",&n,&m,&l,&r);
for (int i=;i<=m;i++)
{
scanf("%d",&x);
cnt[x]++;
}
for (int i=;i<=m;i++) sum[][i]=;
for (int i=;i<=n;i++)
for (int j=;j<=m;j++)
{
int ret;
if (j>=cnt[i]+) ret=(sum[i&^][j]-sum[i&^][j-cnt[i]-]+mod)%mod;
else ret=sum[i&^][j];
sum[i&][j]=(sum[i&][j-]+ret)%mod;
}
printf("%d\n",(sum[n&][r]-sum[n&][l-]+mod)%mod);
return ;
}
BZOJ 1630/2023 Ant Counting 数蚂蚁的更多相关文章
- 1630/2023: [Usaco2005 Nov]Ant Counting 数蚂蚁
2023: [Usaco2005 Nov]Ant Counting 数蚂蚁 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 85 Solved: 40[S ...
- 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 数蚂蚁*&&bzoj1630[Usaco2007 Demo]Ant Counting*
bzoj2023[Usaco2005 Nov]Ant Counting 数蚂蚁&&bzoj1630[Usaco2007 Demo]Ant Counting 题意: t个族群,每个族群有 ...
- 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 ...
- 【bzoj2023/1630】[Usaco2005 Nov]Ant Counting 数蚂蚁 dp
题解: 水题 f[i][j] 前i种用了j个,前缀和优化就可以了
- [poj3046][Ant counting数蚂蚁]
题目链接 http://noi.openjudge.cn/ch0206/9289/ 描述 Bessie was poking around the ant hill one day watching ...
- bzoj1630 / bzoj2023 [Usaco2005 Nov]Ant Counting 数蚂蚁
Description 有一天,贝茜无聊地坐在蚂蚁洞前看蚂蚁们进进出出地搬运食物.很快贝茜发现有些蚂蚁长得几乎一模一样,于是她认为那些蚂蚁是兄弟,也就是说它们是同一个家族里的成员.她也发现整个 ...
- BZOJ2023: [Usaco2005 Nov]Ant Counting 数蚂蚁(dp)
题意 题目描述的很清楚... 有一天,贝茜无聊地坐在蚂蚁洞前看蚂蚁们进进出出地搬运食物.很快贝茜发现有些蚂蚁长得几乎一模一样,于是她认为那些蚂蚁是兄弟,也就是说它们是同一个家族里的成员.她也发现整个 ...
随机推荐
- DSP基础学习-ADC同步采样
DSP基础学习-ADC同步采样 彭会锋 2015-04-28 20:31:06 在DSP28027 LauchPad学习过程中,关于ADC同步采样和顺序采样的区别稍加研究了一下,发现里面还真有些门道, ...
- HTML5自学笔记[ 12 ]canvas绘图小示例之鼠标画线
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- Search for a Range [LeetCode]
Given a sorted array of integers, find the starting and ending position of a given target value. You ...
- 再不用担心DataRow类型转换和空值了(使用扩展方法解决高频问题)
在使用DataRow读取数据时,通常会遇到数据可能为Null, 但是又需要转换为如int等其它类型的数据,因此就通常会写这样的代码: if (dr[name] != DBNull.Value & ...
- 上国际网络——通过配置host
http://laod.cn/hosts/2016-google-hosts.html
- JDE修改Grid列样式
Set Grid Color :to change the background color of a cell, row, column, or the entire control. Set Gr ...
- li排序的两种方法
1.一般做法 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <ti ...
- 深入理解Redis:命令处理流程
Redis是著名的NoSQL键值数据库服务器,为了保证效率,其数据都缓存在内存中.与Memcached相比,Redis支持的数据类型更多,包括String,List,Set,Zset和Hash.下面简 ...
- 关于Android的onResume的2点体会(程序切换之后恢复状态)
Android有点儿差劲:按home键之后,立即长按home键选择程序切换回来,居然activity就跑回初始状态去了. 我的程序里面有2个webview,2个按钮,我做到把他们都恢复了. 1 web ...
- C语言中文件的读取和写入
在C语言中写文件 //获取文件指针 FILE *pFile = fopen("1.txt", //打开文件的名称 "w"); // 文件打开方式 如果原来有内容 ...