
C - Typical Stairs

Input is given from Standard Input in the following format:
N M
a1
a2
.
.
.
aM
Print the number of ways to climb up the stairs under the condition, modulo 1 000 000 007.
6 1
3
4
There are four ways to climb up the stairs, as follows:
10 2
4
5
0
There may be no way to climb up the stairs without setting foot on the broken steps.
100 5
1
23
45
67
89
608200469
Be sure to print the count modulo 1 000 000 007.
void coder_solution() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
const long long mod = 1000000007;
int n, m;
cin >> n >> m;
vector<int> vi(m);
vector<long long> dp(n + 1);
long long ans = 0;
dp[0] = 1;
dp[1] = 1;
for (int i = 0; i < m; i++) {
cin >> vi[i];
if (vi[i] == 1) {
dp[1] = 0;
ans++;
}
}
for (int i = 2; i <= n; i++) {
if (i == vi[ans]) {
dp[i] = 0;
ans++;
} else {
dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
}
}
cout << dp[n];
}
void coder_solution() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
const long long mod = 1000000007;
int n, m, temp;
cin >> n >> m;
vector<bool> vb(n, false);
vector<long long> dp(n + 1);
dp[0] = 1;
dp[1] = 1;
for (int i = 0; i < m; i++) {
cin >> temp;
vb[temp - 1] = true;
if(temp == 1) {
dp[1] = 0;
}
}
for (int i = 2; i <= n; i++) {
if (!vb[i - 1]) {
dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
}
}
cout << dp[n];
}
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7, mod = 1e9 + 7;
int n, m, a[N], f[N];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1, x; i <= m; i++) {
scanf("%d", &x), a[x] = 1;
}
f[0] = 1;
for (int i = 1; i <= n; i++) {
if (!a[i]) {
f[i] = (f[i - 1] + f[i - 2]) % mod;
}
}
printf("%d\n", f[n]);
}