結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2023-03-31 02:43:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 148 ms / 5,000 ms |
コード長 | 749 bytes |
コンパイル時間 | 3,550 ms |
コンパイル使用メモリ | 251,432 KB |
最終ジャッジ日時 | 2025-02-11 19:26:55 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using ll=long long;using ld=long double;ld pie=3.141592653589793;ll mod=1000000007;ll inf=999999999999999999;int main(){ll n;cin >> n;vector<vector<ll>>dp(n+10,vector<ll>(4,0));dp[1][1]=1;dp[2][2]=1;dp[3][3]=1;for (ll i = 1; i < n; i++){for (ll j = 1; j <= 3; j++){for (ll k = 1; k <= 3; k++){if (j==k){continue;}dp[i+k][k]+=dp[i][j];dp[i+k][k]%=mod;}}}ll ans=dp[n][1]+dp[n][2]+dp[n][3];ans%=mod;cout << ans << endl;}