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的更多相关文章
随机推荐
- RNN(二)——基于tensorflow的LSTM的实现
lstm的前向结构,不迭代 最基本的lstm结构.不涉及损失值和bp过程 import tensorflow as tf import numpy as np inputs = tf.placehol ...
- Linux配置Tomcat8080端口 远程无法访问解决办法
是因为Linux的防火墙没有开放8080端口 解决办法: /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT #开启8080端口 /sbin/ ...
- 数据结构实验之二叉树七:叶子问题(SDUT 3346)
#include <bits/stdc++.h> using namespace std; struct node { char data; struct node *lc, *rc; } ...
- ES6 import、export的写法
大家都知道来到ES6版本,ES就原生支持JS Module的概念. import和export的写有哪些呢,我们看看 import: import from 和 var 变量一样,也会存在提升,这意味 ...
- python pywin32 安装
pip install pywin32 参考: https://blog.csdn.net/qq_38161040/article/details/85075158
- js和jQuery实现的Ajax
1. JS实现Ajax <!doctype html> <html lang="en"> <head> <meta charset=&qu ...
- gdb常用的调试命令
首先将源代码编译.链接生成debug版本的可执行文件,然后通过‘gdb debug版本的可执行文件名’进入调试模式. a) 单进程.单线程基础调试命令 l 显示main函数所在的文件的源代码 ...
- Web Services之基本认识
参考:http://www.w3school.com.cn/webservices 1.什么是Web Services Web Services 可使您的应用程序成为 Web 应用程序.Web Ser ...
- 网络时间协议 (SNTP)
sntp是简单网络时间协议(Simple Network Protocol)的客户端,可以用来查询或修正NTP服务器的时间和本地的时差. sntp可以以非交互模式运行或运行一个计划任务的脚本. snt ...
- Spring事务管理4-----声明式事务管理(2)
声明式事务管理 基于AspectJ的 XML 方式配置 通过对事务管理器TransactionManager配置通知(增强),然后再配置切点和切面,详细见applicationContext.xml ...