URAL - 2018 The Debut Album dp

运放+三极管恒流源电路设计实战:从原理到仿真一步到位(附Multisim文件) 本文详细解析了运放与三极管构建恒流源电路的核心原理,重点阐述了负反馈机制如何实现精准的电流控制。通过Multisim仿真实战,从电路搭建、参数计算到负载调整率与动态响应分析,一步步指导设计过程,并提供常见故障的调试技巧与PCB设计要点,帮助工程师从理论平稳过渡到可靠实践。 阅读详情

2018. The Debut Album

Time limit: 2.0 second
Memory limit: 64 MB
Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes.
The producer of the group said that the album should consist of n remixes. On second thoughts the musicians decided that the album will be of interest only if there are no more than a remixes on “My love” in a row and no more than b remixes on “I miss you” in a row. Otherwise, there is a risk that even the most devoted fans won’t listen to the disk up to the end.
How many different variants to record the album of interest from n remixes exist? A variant is a sequence of integers 1 and 2, where ones denote remixes on “My love” and twos denote remixes on “I miss you”. Two variants are considered different if for some i in one variant at i-th place stands one and in another variant at the same place stands two.

Input

The only line contains integers n, a, b (1 ≤ a, b ≤ 300; max(a,b) + 1 ≤ n ≤ 50 000).

Output

Output the number of different record variants modulo 109+7.

Sample

input output
3 2 1
4

Notes

In the example there are the following record variants: 112, 121, 211, 212.
Problem Author: Olga Soboleva (prepared by Alex Samsonov)
Problem Source: NEERC 2014, Eastern subregional contest

题意是给你n,a,b,构造一个由1和2构成的长度为n的序列,其中不能有连续a个1,和连续b个2

问有多少种这样的序列

刚开始题意看错了,一直想推公式,最后发现。。。。。。。。

dp【i】【j】表示长度为i并且第i个字符为j的序列个数                

显然j只有1和2两个取值

dp【i】【1】=sum(dp【i-k】【2】)(k<=a);

dp【i】【2】=sum(dp【i-k】【1】)(k<=b)                   

因为这个位置是2,前面只能是前一个位置是1或前一个位置是2并且前两个位置是1或者。。。。。前b-1个位置是2并且前b个位置是1

#include<bits/stdc++.h>
using namespace std;
long long dp[500005][2];
const long long mo=1e9+7;
int main()
{
    int n,a,b,i,j;
    cin>>n>>a>>b;
    dp[1][1]=dp[1][2]=1;
    dp[0][1]=dp[0][2]=1;
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=a;j++)
        {
            if(i-j<0)
                break;
            dp[i][1]=(dp[i][1]+dp[i-j][2])%mo;
        }
        for(j=1;j<=b;j++)
        {
            if(i-j<0)
                break;
            dp[i][2]=(dp[i-j][1]+dp[i][2])%mo;
        }
    }
  //  cout<<dp[n][1]<<" "<<dp[n][2]<<endl;
    cout<<(dp[n][1]+dp[n][2])%mo<<endl;
    return 0;
}


分布式优化 (Distributed Optimization) 算法详解及案例分析 分布式优化是一种将优化问题分解为多个子问题并在多个计算节点上并行求解的方法。其目标是通过分布式计算资源高效地求解大规模优化问题。 阅读详情

相关推荐

NC数据预处理避坑指南:从MATLAB读取到GeoTIFF导出,解决坐标翻转与值域异常

本文详细解析了NC数据预处理中的常见问题,包括MATLAB读取时的坐标翻转与GeoTIFF导出时的值域异常。通过实战案例,介绍了如何解决矩阵方向错乱、处理FillValue与scale_factor、精准移植空间参考等关键问题,帮助研究者高效完成气象数据的批量处理与GIS兼容性验证。

weixin_30788619的博客 660

ural 2018 The Debut Album(dp¥)

2018. The Debut Album Time limit: 2.0 secondMemory limit: 64 MB Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, ...

weixin_30530523的博客 179

零代码搭建专业知识库:Wiki.js+cpolar让团队协作像写笔记一样简单

"项目文档又找不到了!“团队负责人小张第N次在群里看到这样的抱怨——技术文档分散在邮件、网盘和个人电脑里,新人入职要花一周熟悉文档位置,远程协作时版本混乱更是家常便饭。Wiki.js与cpolar内网穿透服务的出现,就像给团队协作装上了"中央大脑”,用写Markdown笔记的简单方式,搭建一个专业的知识库系统。普通人对知识管理的需求其实很简单:方便记录、容易查找、大家能用。但传统方案把这个过程搞得异常复杂:建服务器、配环境、学语法、搞权限……大部分团队还没开始就放弃了。

Yawesh的博客 2044

【二进制 && bitset】URAL - 2108 Oleg and Little Ponies

Problem Description 输入n, m分别代表二进制串的长度 和 有m对串的转换。 再给你一个当前串。 串的转换是指:如果当前串&左串=当前串,那么当前串|左串。 m对串你随便使用来转换,让你求最后 输出当前串。 例子 6 4 111000 101000 110000 111000 010000 100000 000010

ACMer 梁剑锋 的博客 270

USRP N210与MATLAB连接实战:从驱动安装到信号接收

本文详细介绍了USRP N210与MATLAB连接的完整流程,涵盖驱动安装、网络配置、支持包安装及信号接收实战。重点解决了安装过程中的常见错误和硬件连接问题,并通过MATLAB代码示例展示了如何配置接收器、处理信号数据,帮助用户快速实现从设备对接到信号分析的全过程。

blue的专栏 830

MultiOTP Credential Provider避坑指南:从安装到RDP双因素认证的全流程解析

本文详细解析了MultiOTP Credential Provider从安装到实现RDP双因素认证(MFA)的全流程,重点分享了Docker部署、Active Directory集成及网络级认证(NLA)兼容性等环节的实战避坑经验,旨在帮助运维人员高效、稳定地部署离线双因素认证方案,提升Windows远程桌面安全性。

weixin_29255731的博客 658

DAG上的动态规划之再次思考(QDUoj分辣条2)

https://qduoj.com/problem/99/ 分辣条2 发布时间: 2016年7月2日 21:47   最后更新: 2016年7月2日 21:51   时间限制: 1000ms   内存限制: 128M 描述 啊啊有根很大的辣条,重量为n,啊啊想把辣条分给很多小朋友,但是必须满足下列条件: 1.每个小朋友分得的辣条重量为a,b或c; 2.分得辣条的

Rain 725

高通Camx架构调试不求人:手把手教你开UMD/KMD Log与Dump图像(附离线Log合成脚本)

本文详细介绍了高通Camx架构的调试方法,包括UMD/KMD Log的精准配置与图像Dump技术,帮助工程师快速定位移动影像系统中的问题。通过实战案例和自动化脚本,提升调试效率,适用于图像色彩异常、帧率波动等常见问题的诊断与解决。

weixin_30516243的博客 258

URAL - 2018 The Debut Album (递推)

【题意】给你三个数n, a, b;表示对于一个长度为n且只有‘A’和‘B’ 的字符串,连续的‘A’ 的个数不能超过a个,‘B’不能超过b个。有多少种不同的字符串。 【分析】f[i][j][0] 表示长度为i的字符串,最后面连续j个都是‘A’的情况下有多少种,f[i][j][1]同样的意义表示‘B’。很明显当 j > 1 时 f[i][j][0] = f[i - 1][j -1][0]。但当j ==

cysjiang的博客 323

Autodesk全家桶:从AutoCAD到Maya,设计师必备的7款神器全解析

本文全面解析Autodesk全家桶中的7款设计师必备软件,包括AutoCAD、Revit、Inventor、Fusion 360、Maya和3ds Max等。从二维制图到三维建模,从建筑信息模型(BIM)到影视动画制作,这些工具在工程设计、建筑可视化和数字创意领域展现出强大的协同效应。通过实战案例展示如何整合工作流,显著提升设计效率与项目质量。

weixin_29237635的博客 468

【TCAD】Sentaurus 中的“陷阱trap”仿真设置

允许使用有限的数据集名称 SFactor 规范,例如 DeepLevels , xMoleFraction , 和 yMoleFraction (从兴奋剂档案中读取) eTrappedCharge 和 hTrappedCharge (从指定的文件中读取 DevFields 在 File 部分)或 PMI 用户字段 PMIUserField0...10 (从指定的文件中读取 PMIUserFields 在 File 部分)。给定的陷阱截面 eNeutral 陷阱是多种多样的 Xsec 项目参数。

荷塘阅色 1317

qduoj 140 题目6 组合数学

题目链接 思路: 算是一个比较考验思维的组合数学题目吧,当时只是大体一看没啥思路就换题了,结果自己傻逼搞个物理题什么都是对的结果把输入的变量整反了一直wa到比赛结束前一秒才想起来,然而已经晚了.....现在回头再看这个题目觉得还是很简单的.       首先我们可以把n个x的和看成X,再把m个y的值看成Y,因为k的范围很小,所以我们可以去O(n^2)枚举X和Y,找到所有或起来为k的可行解,然

Marcus-Bao的个人主页 714

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

URAL 2018 The Debut Album DP中滚动数组用法

题目描述:Description Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes. The pr

喵头鹰的博客 674

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

☆URAL 2018 The Debut Album (dp 两种写法)

2018. The Debut Album Time limit: 2.0 second Memory limit: 64 MB Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss yo

K键盘里的青春K 608

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

URAL 2018 The Debut Album(DP)

2018. The Debut Album Time limit: 2.0 second Memory limit: 64 MB Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss yo

AI蜗牛之家 1320

Ural 2018The Debut Album(DP)

题目地址:Ural 2018 简单DP。用滚动数组。 代码如下: #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define LL __int64 const int INF

scf0920 1133

【DP】URAL 2018 The Debut Album

Problem Description 给你n个数,由1,2组成,连续1的个数不能超过a,连续2的个数不能超过b。 Input The only line contains integers n, a, b (1 ≤ a, b ≤ 300; max( a, b) + 1 ≤ n ≤ 50 000). Output Output the number of different record

ACMer 梁剑锋 的博客 351

URAL_2018_The Debut Album(滚动数组DP)

题型:动态规划 题意:构造长度为n的串,

Light_starlight 1238

URAL 2018 The Debut Album(dp)

题目链接 2018. The Debut Album Time limit: 2.0 second Memory limit: 64 MB Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I m

madaidao的专栏 793

URAL2018——The Debut Album(DP)

G - The Debut Album   Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes

我在浪里 406

G - The Debut Album URAL - 2018(dp)

Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes. The producer of t

DS00HY的小博客 355

ural 2018. The Debut Album 滚动数组dp

点击打开链接 2018. The Debut Album Time limit: 2.0 second Memory limit: 64 MB Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love

代码改变世界,keep coding。 1370

ural 2018 The Debut Album (dp)

题意:有两个物品,两个物品连续放分别最多放a,b个,输出总共放n个的方案数 分析:考虑dp[n][p],表示最后放p,总共放n个方案数,就很简单了 #include<iostream> #include<cstdio> using namespace std; const int maxn=5e4+5; const int mod=1e9+7; ...

weixin_30294709的博客 106

URAL 2018. The Debut Album (dp)

Description Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes. The pr

小坏蛋_千千 691

G - The Debut Album URAL - 2018 (dp滚动数组)

Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes. The producer of the gro...

qq_44134712的博客 208
上一篇: 数位dp
下一篇: HDU - 5974 A Simple Math Problem 解方程
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值