2018. The Debut Album
2015-02-09 17:07
330 查看
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] 类似
真心爱过,怎么能彻底忘掉
题目大意:
长度为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 ; unsigned int dpb ; 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 +dpb )%MOD)<<endl; return 0; }
相关文章推荐
- Ural 2018 The Debut Album
- 【DP】URAL 2018 The Debut Album
- URAL - 2018 The Debut Album(状态dp 记忆化搜索)
- URAL 2018 The Debut Album (DP)
- URAL 2018. The Debut Album (dp)
- G - The Debut Album URAL - 2018(dp)
- ☆URAL 2018 The Debut Album (dp 两种写法)
- URAL - 2018 The Debut Album
- URAL - 2018 The Debut Album dp
- URAL_2018_The Debut Album(滚动数组DP)
- ural 2018 The Debut Album (dp)
- URAL 2018 The Debut Album(DP)
- URAL 2018 The Debut Album(dp)
- Ural 2018. The Debut Album
- Ural 2018 The Debut Album
- The Debut Album (dp + 滚动数组)
- 【动态规划】Gym - 100507G - The Debut Album
- codeforces (G) The Debut Album dp+滚动数组
- G - The Debut Album
- Release My New Single Album: Open The Door