2018. The Debut Album
http://acm.timus.ru/problem.aspx?space=1&num=2018
真心爱过,怎么能彻底忘掉
题目大意:
长度为n的串,由1和2组成,连续的1不能超过a个,连续的2不能超过b个
dpa[i] 表示长度为i时以a为结尾的串的个数,dpb[i] 类似
求dpa[i]时 需要枚举结尾a的个数就可以了 dpb[i] 类似
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h> using namespace std; const int N=50001;
const int M=301;
const unsigned int MOD=1000000007;
unsigned int dpa[N];
unsigned int dpb[N];
int main()
{
//freopen("data.in","r",stdin);
memset(dpa,0,sizeof(dpa));
memset(dpb,0,sizeof(dpb));
int n,a,b;
cin>>n>>a>>b;
dpa[0]=dpb[0]=1;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=a&&j<=i;++j)
{
dpa[i]=(dpa[i]+dpb[i-j])%MOD;
}
for(int j=1;j<=b&&j<=i;++j)
{
dpb[i]=(dpb[i]+dpa[i-j])%MOD;
}
}
cout<<((dpa[n]+dpb[n])%MOD)<<endl;
return 0;
}
2018. The Debut Album的更多相关文章
- ural 2018 The Debut Album(dp¥)
2018. The Debut Album Time limit: 2.0 secondMemory limit: 64 MB Pop-group “Pink elephant” entered on ...
- URAL 2018 The Debut Album (DP)
题意:给出n长度的数列,其实1的连续个数不超过a,2的连续个数不超过b. 析:dp[i][j][k] 表示前 i 个数,以 j 结尾,并且连续了k个长度,要用滚动数组,要不然MLE. 代码如下: #p ...
- Gym 100507G The Debut Album (滚动数组dp)
The Debut Album 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/G Description Pop-group & ...
- Ural 2018The Debut Album(DP)
题目地址:Ural 2018 简单DP.用滚动数组. 代码例如以下: #include <iostream> #include <cstdio> #include <st ...
- 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem G. The Debut Album
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定n,a,b的值 求一个长度为n的 ...
- 【动态规划】Gym - 100507G - The Debut Album
一般思路的dp是用f(i,j,0)表示前i位最后有j个1的方案数,用f(i,j,1)表示前j位最后有j个2的方案数,j都是大于等于1的,然后比较容易转移. 但这题卡内存,就只能用f(i,j)表示前i位 ...
- NEERC 2014, Eastern subregional contest
最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...
- 递推,求至少连续放置三个U的危险组合
UVA580-Critical Mass 题意 有两种方块,L和U,有至少三个连续的U称为危险组合,问有多少个危险组合 solution: 至少这个概念比较难求 ,所以转化为(1ll<<n ...
- Json.net 常用使用小结
using System; using System.Linq; using System.Collections.Generic; namespace microstore { public int ...
随机推荐
- Excel-漏斗图分析(差异分析)
漏斗图适用于业务流程比较规范.周期长.环节多的流程分析,通过漏斗各环节业务数据的比较,能够直观地发现和说明问题所在.在网站分析中,通常用于转化率比较,它不仅能展示用户从进入网站到实现购买的最终转化率, ...
- sudo: no tty present and no askpass program specified(转)
sudo: no tty present and no askpass program specified 2012-11-30 09:30 5040人阅读 评论(1) 收藏 举报 修改sudo配置文 ...
- 将自己库添加Cocoapods支持
给库添加Cocoapods支持, 使这个工具使用起来更加方便, 更好的使用Cocoapods, 助力iOS程序开发, 下面进入正题, 想要实现这个过程, 绝对不虚此读. 首先写好一个要添加Cocoap ...
- hihoCoder太阁最新面经算法竞赛19
比赛链接:http://hihocoder.com/contest/hihointerview28/problems A. 固定一个方向,两两相邻的点顺时针或逆时针构造三个向量,判断这个点在这个向量的 ...
- php : 配置
一. php: undefined function mysql_connect() mac 上操作 一.有可能是因为版本不同而引起的 PHP5中使用mysql_connect()函数进行连接.但P ...
- GNS3 IOU 配置
GNS3使用视频: http://edu.51cto.com/lesson/id-25295.html GNS3 IOU 与VM http://www.mamicode.com/info-detail ...
- 分组找ID
select t.name1,t.name2,t.zx from (select row_number()over(partition by name1 order by zx desc)rn, te ...
- hibernate hql
hibernate在使用hql进行select count(*) from ObjectA left join fetch apath 时会报错,多余的left join去掉即可.
- IDEA建立---- java web项目
1.新建一个javaweb项目 2.给项目命名 3.建立完的项目结构大概是这样(在web 下新建 两个目录lib 和 classes) 4.找到project Structure---------&g ...
- Android NDK 初探,生成so文件以及调用so文件方法
因为最近业务上涉及安全的问题 然后有一些加密解密的方法和key的存储问题 本来想存储到手机里面,但是网上说一般敏感信息不要存储到手机Sdcard上 而且我这个如果从网络建立通信获取的话,又太耗时,所以 ...