結果
問題 | No.533 Mysterious Stairs |
ユーザー | YukiDaruma |
提出日時 | 2017-06-23 22:49:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 5,000 ms |
コード長 | 776 bytes |
コンパイル時間 | 1,695 ms |
コンパイル使用メモリ | 167,352 KB |
実行使用メモリ | 26,968 KB |
最終ジャッジ日時 | 2024-10-04 07:44:54 |
合計ジャッジ時間 | 2,352 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1000000; const int iMod = 1000000007; long long Step1[ MAX_N + 5 ]; long long Step2[ MAX_N + 5 ]; long long Step3[ MAX_N + 5 ]; int main( int argc, char *argv[] ) { int i; int N; long long iAns; ios::sync_with_stdio( false ); cin.tie( 0 ); cin >> N; Step1[ 1 ] = 1; Step2[ 2 ] = 1; Step3[ 3 ] = 1; for( i = 1; i < N; i++ ) { Step1[ i + 1 ] += Step2[ i ]; Step1[ i + 1 ] += Step3[ i ]; Step2[ i + 2 ] += Step1[ i ]; Step2[ i + 2 ] += Step3[ i ]; Step3[ i + 3 ] += Step1[ i ]; Step3[ i + 3 ] += Step2[ i ]; Step1[ i + 1 ] %= iMod; Step2[ i + 2 ] %= iMod; Step3[ i + 3 ] %= iMod; } iAns = Step1[ N ] + Step2[ N ] + Step3[ N ]; iAns %= iMod; cout << iAns << endl; return 0; }