定西+简单dp

定西

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;
}
posted @ 2020-10-07 10:02  Garrett_Wale  阅读(103)  评论(0编辑  收藏  举报