結果
問題 | No.533 Mysterious Stairs |
ユーザー |
|
提出日時 | 2020-05-22 12:42:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 80 ms / 5,000 ms |
コード長 | 644 bytes |
コンパイル時間 | 1,591 ms |
コンパイル使用メモリ | 170,916 KB |
実行使用メモリ | 57,852 KB |
最終ジャッジ日時 | 2024-10-04 09:56:16 |
合計ジャッジ時間 | 2,915 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair<int,int> ; using pll = pair<long long,long long>; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; int main(){ int n; cin >> n; vector<vector<ll>> dp(n,vector<ll>(3,0)); rep(i,min(n,3)){ dp[i][i] = 1; } rep(i,n){ rep(j,3){ if(i-j-1>=0){ dp[i][j] = (dp[i-j-1][(j+1)%3] + dp[i-j-1][(j+2)%3])%MOD; } } } cout << (dp[n-1][0] + dp[n-1][1] + dp[n-1][2])%MOD << endl; return 0; }