POJ3046ANT_COUNTING
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <map> using namespace std;
const int MAX_A = ;
const int MAX_T = ;
int T, A, S, B;
int a[MAX_T];
int dp[][MAX_A];
const int MOD = 1e6; int main(void)
{
cin>>T>>A>>S>>B;
//输入组别的数量、蚂蚁的数量、起始的地方、终止的地方
int x;
for(int i = ; i < A; i++){
scanf("%d", &x); //组的编号其实是 0 到 T - 1
a[x-]++;
}
//UNIT OPTION
memset(dp, , sizeof(dp));
for(int i = ; i <= a[]; i++) dp[][i] = ;
// END OF INIT
for(int i = ; i < T; i++){
if(i & ){
memset(dp[], , sizeof(dp[]));
for(int j = ; j <= B; j++){
for(int k = ; k <= a[i] && k <= j; k++){
dp[][j] += dp[][j-k], dp[][j] %= MOD;
}
}
}
else{
memset(dp[], , sizeof(dp[]));
for(int j = ; j <= B; j++){
for(int k = ; k <= a[i] && k <= j; k++){
dp[][j] += dp[][j-k], dp[][j] %= MOD;
}
}
}
}
int res = ;
// printf("SHOW THE TMEP\n");
if((T - ) & ){
// for(int i = 0; i < S; i++) printf(" i %d : %d\n", i, dp[1][i]);
for(int i = S; i <= B; i++){
// printf(" i %d : %d\n", i, dp[1][i]);
res += dp[][i];
res %= MOD;
}
}
else{
// for(int i = 0; i < S; i++) printf(" i %d : %d\n", i, dp[0][i]);
for(int i = S; i <= B; i++){
// printf(" i %d : %d\n", i, dp[0][i]);
res += dp[][i];
res %= MOD;
}
}
// printf("THE RESULT : ");
printf("%d\n", res);
return ;
}
注意 剩余 后 6 位; 然后你需要 MOD 1E6; 并不是 1E7 !!!!!!!!
POJ3046ANT_COUNTING的更多相关文章
随机推荐
- C++ 2048游戏
2048游戏实现起来还是比较简单的,注意几个细节,调几个bug就好了. 直接上源码,需要的可以拿走(手动滑稽 /*dos windows 25*80*/#include <algorithm&g ...
- jumpserver官方手动安装
测试环境 CPU: 64位双核处理器 内存: 4G DDR3 数据库:mysql 版本大于等于 5.6 mariadb 版本大于等于 5.5.6 环境 系统: CentOS 7 IP: 192.168 ...
- xpath简介备查
xpath简介 xpath 使用路径表达式在xml和html中进行导航 xpath包含标准函数库 xpath是一个w3c的标准 xpath节点关系 父节点 子节点 同袍节点 先辈节点 后代节点 xpa ...
- java集合类-List接口
List接口包含List接口及List接口的所有实现类,List集合中的元素允许重复. List接口 List接口继承了Collection接口,包含Collection接口的所有方法,还定义了两个非 ...
- 2019.6.28 校内测试 T3 【音乐会】道路千万条
大眼一看最下面的题意解释的话,发现这和洛谷P1310表达式的值挺像的,大概都是给定一些运算符号,让最后的表达式为true的概率,为false的概率啥的QwQ~: 然后这个题嘛?就是在所有的运算符中提溜 ...
- 解决node-sass无法下载的问题
本文链接:https://blog.csdn.net/qq383366204/article/details/86605960在国内用npm安装依赖的时候经常都会有各种奇怪的问题,个人强烈推荐用yar ...
- AGC009C Division into Two
题意 有\(n\)个严格升序的数,请你分成两个集合\(A\)和\(B\),其中一个集合任意两数之差不小于\(x\),另一集合任意两数之差不小于\(y\). 问方案数,集合可以为空. $n \le 10 ...
- Web开发中 MTV模式与MVC模式的区别 联系 概念
MTV 与 MVC模式的区别 联系 概念: MTV: 所谓MTV指的就是: M:model (模型),指的是ORM模型. T:template (模板),一般Python都是使用模板渲染的方式来把HT ...
- tomcat单机多实例
catalina.home指向公用信息的位置,就是bin和lib的父目录. catalina.base指向每个Tomcat目录私有信息的位置,就是conf.logs.temp.webapps和work ...
- P1944 最长括号匹配_NOI导刊2009提高(1)
P1944 最长括号匹配_NOI导刊2009提高 题解 宁愿相信世上有鬼,也不能随便相信某谷题目标签 我想了半天然后看了眼题解,发现用栈来模拟就好了 栈来模拟,还要用到一个bool数组,标记是否已经匹 ...