結果
問題 | No.533 Mysterious Stairs |
ユーザー |
|
提出日時 | 2017-10-06 16:32:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 37 ms / 5,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 995 ms |
コンパイル使用メモリ | 55,132 KB |
実行使用メモリ | 15,232 KB |
最終ジャッジ日時 | 2024-11-17 00:32:17 |
合計ジャッジ時間 | 1,902 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include<iostream> #include<string.h> using namespace std; const int limn = 1e6; int dp[limn+10][3]; int divn = 1e9 + 7; int main(){ memset(dp,0,sizeof(dp)); int n; cin >> n; dp[0][0] = 1; for(int i = 0;i < n;i++){ for(int j = 0;j < 3;j++){ for(int k = 0;k < 3;k++){ if(i==0){ dp[i+k+1][k] = (dp[i+k+1][k] + dp[i][j]) % divn; }else{ if(j != k){ dp[i+k+1][k] = (dp[i+k+1][k] + dp[i][j]) % divn; } } } } } int ans = 0; for(int i = 0;i < 3;i++) ans = (ans + dp[n][i]) % divn; cout << ans << endl; return 0; }