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 ...
随机推荐
- getFragmentManager()和getSupportFragmentManager()
在Android开发中,少不了Fragment的运用.目前在实际运用中,有v-4包下支持的Fragment以及app包下的Fragment,这两个包下的FragmentManager获取方式有点区别, ...
- JavaScript学习笔记(一):介绍JavaScript的一些简单知识
JavaScript是世界上最流行的编程语言.这门语言可用于HTML和web,更可广泛用于服务器.PC.笔记本电脑和智能手机等设备.---------------------------------- ...
- Linux查看程序端口占用情况
今天发现服务器上Tomcat 8080端口起不来,老提示端口已经被占用. 使用命令: ps -aux | grep tomcat 发现并没有8080端口的Tomcat进程. 使用命令:netstat ...
- Android TabHost使用
TabHost是Android中自带的选项卡控件,效果图如下: 主布局文件 <RelativeLayout xmlns:android="http://schemas.android. ...
- Linux 内核编译
注:该文章部分内容摘录自以下链接. http://www.cnblogs.com/zhunian/archive/2012/04/04/2431883.html 创建内核的第一步是创建一个 .conf ...
- c#winform程序退出的方法
一共有4种方式: 1.this.Close(); 只是关闭当前窗口,若不是主窗体,无法退出程序,另外若有托管线程(非主线程),也无法干净的退出: 2.Application.Exit();强制所有消 ...
- 基于注解的Spring AOP的配置和使用
摘要: 基于注解的Spring AOP的配置和使用 AOP是OOP的延续,是Aspect Oriented Programming的缩写,意思是面向切面编程.可以通过预编译方式和运行期动态代理实现在不 ...
- 【java基础】面向对象的三大基本特征之-------继承
面向对象的三大特征:封装,继承,多态 java通过extends关键字来实现继承,而且是单继承,一个子类只可以有一个直接父类,但是父类还可以有父类... java.long.Object是所有类的父类 ...
- VMware虚拟机12安装linux系统
http://jingyan.baidu.com/article/4f7d5712d20a1b1a21192760.html 阿里云开源镜像站:http://mirrors.aliyun.com/
- ichecked 全选、反选
//iChecked复选框的全选.反选var checkBox =function (checkParents){ $(checkParents).find('.minimalCheckBox1'). ...