VM 08 Bài 01 - Bậc thang
View as PDFBờm chơi trò chơi điện tử Lucky Luke đến màn phải điều khiển Lucky leo lên một cầu thang gồm ~N~ bậc.
Các bậc thang được đánh số từ 1 đến ~N~ từ dưới lên trên. Lucky có thể đi lên một bậc thang, hoặc nhảy một bước lên hai bậc thang. Tuy nhiên một số bậc thang đã bị thủng do cũ kỹ và Lucky không thể bước chân lên được. Biết ban đầu, Lucky đứng ở bậc thang số 1 (bậc thang số 1 không bao giờ bị thủng).
Chơi đến đây, Bờm chợt nảy ra câu hỏi: có bao nhiêu cách để Lucky leo hết được cầu thang? (nghĩa là leo đến bậc thang thứ ~N~). Bờm muốn nhờ bạn trả lời câu hỏi này.
Input
Dòng đầu tiên: gồm 2 số nguyên ~N~ và ~K~, là số bậc của cầu thang và số bậc thang bị hỏng ~(0 \le K < N \le 10^5)~.
Dòng thứ hai: gồm ~K~ số nguyên cho biết chỉ số của các bậc thang bị hỏng theo thứ tự tăng dần.
Output
In ra phần dư của số cách Lucky leo hết cầu thang khi chia cho 14062008.
Sample Input 1
4 2
2 3
Sample Output 1
0
Sample Input 2
90000 1
49000
Sample Output 2
4108266
Comments
dp đếm
dùng dp là ra
bài này hay ấy
include<bits/stdc++.h>
define ll long long
using namespace std; const int N = 1e5 + 5; const int MOD = 14062008; ll n , k , dp[N] , a[N]; bool check[N]; int main() { iosbase::syncwith_stdio(false); cin.tie(nullptr);
for(ll i=1;i<=N;++i) check[i] = true; cin >> n >> k; for(ll i=1;i<=k;++i) { ll x; cin >> x; check[x] = false; } dp[1] = 1; for(ll i=2;i<=n;++i) { if(check[i] == 0) dp[i] = 0; else dp[i] = (dp[i-1] + dp[i-2]) % MOD; } cout << dp[n]; return 0; }
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
bà giỡn hoài bà ơi
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
bài hay quá
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
cho em hoi bai nay lam sao a?
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
day fibonaci
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.