定西

ECNU-3531

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<unordered_map>
#include<bitset>
#include<sstream>
using namespace std;
const int maxn=103;
int dp[maxn];
bool broke[maxn];
int main(){
memset(broke,false,sizeof(broke));
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++){
int x;
cin>>x;
broke[x]=true;
}
dp[0]=1;
for(int i=1;i<=n;i++){
if(broke[i]){
dp[i]=0;
}else{
if(i>=3)
dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
else if(i>=2){
dp[i]=dp[i-1]+dp[i-2];
}else{
dp[i]=dp[i-1];
}
}
}
cout<<dp[n]<<endl;
return 0;
}

定西+简单dp的更多相关文章

  1. HDU 1087 简单dp,求递增子序列使和最大

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  2. Codeforces Round #260 (Div. 1) A. Boredom (简单dp)

    题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...

  3. codeforces Gym 100500H A. Potion of Immortality 简单DP

    Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...

  4. 简单dp --- HDU1248寒冰王座

    题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...

  5. poj2385 简单DP

    J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit ...

  6. hdu1087 简单DP

    I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     ...

  7. poj 1157 LITTLE SHOP_简单dp

    题意:给你n种花,m个盆,花盆是有顺序的,每种花只能插一个花盘i,下一种花的只能插i<j的花盘,现在给出价值,求最大价值 简单dp #include <iostream> #incl ...

  8. hdu 2471 简单DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571 简单dp, dp[n][m] +=(  dp[n-1][m],dp[n][m-1],d[i][k ...

  9. Codeforces 41D Pawn 简单dp

    题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...

随机推荐

  1. tomacat服务器上web资源访问流程、web应用打成war包发布、Context的reloadable属性、tomacat体系架构

    一.web资源访问流程 二.web应用打成war包发布到服务器 好处:打成war包发布到服务器,那么服务器会自动把它拆解成文件夹 jar命令是java自带的一个命令,如果之前配置过Java编译环境就可 ...

  2. Matching Engine For Laravel(基于redis的撮合引擎),PHP高性能撮合引擎

    Laravel Package for Matching Engine 快速开始 github地址 安装: composer require sting_bo/mengine 复制配置文件: php ...

  3. MySQL 索引的类型

    主键索引(PRIMARY KEY) # 主键 = 唯一键索引 + 非空 + 只能设置一个字段 # 创建表的时候创建主键索引 mysql> create table test(id int not ...

  4. select(),fd_set(),fd_isset()

    1. select函数 1. 用途 在编程的过程中,经常会遇到许多阻塞的函数,好像read和网络编程时使用的recv, recvfrom函数都是阻塞的函数,当函数不能成功执行的时候,程序就会一直阻塞在 ...

  5. Python import本地模块

    无法识别本地模块 在pycharm中选择文件夹Mark Directory as -> Source root. 或者使用sys.path.append()添加文件夹路径 还是报错ImportE ...

  6. ZOJ 2563 Long Dominoes(状压DP)题解

    题意:n*m的格子,用1 * 3的矩形正好填满它,矩形不能重叠,问有几种填法 思路:poj2411进阶版.我们可以知道,当连续两行的摆法确定,那么接下来的一行也确定.当第一行还有空时,这时第三行必须要 ...

  7. 最新 uni-app 免费教程

    最新 uni-app 免费教程 uni-app 快速入门 steps 建议第一步,看完uni-app官网的首页介绍. 建议第二步,通过快速上手,亲身体验下uni-app. 建议第三步,看完<un ...

  8. DNS & HTTPS bug

    DNS & HTTPS bug SSL protocol version bug https://typescript-4.x-tutorials.xgqfrms.xyz/ errors Th ...

  9. css & auto height & overflow: hidden;

    css & auto height & overflow: hidden; {overflow: hidden; height: 100%;} is the panacea! {溢出: ...

  10. TypeScript & global.d.ts

    TypeScript & global.d.ts https://www.typescriptlang.org/docs/handbook/declaration-files/template ...