結果

問題 No.533 Mysterious Stairs
ユーザー shotshot
提出日時 2017-06-23 23:27:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 801 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 159,752 KB
実行使用メモリ 76,400 KB
最終ジャッジ日時 2024-04-15 01:07:23
合計ジャッジ時間 2,991 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
34,576 KB
testcase_01 AC 12 ms
34,572 KB
testcase_02 AC 10 ms
34,688 KB
testcase_03 AC 10 ms
34,756 KB
testcase_04 AC 11 ms
34,668 KB
testcase_05 AC 11 ms
34,628 KB
testcase_06 AC 11 ms
34,484 KB
testcase_07 AC 11 ms
34,736 KB
testcase_08 AC 11 ms
34,532 KB
testcase_09 AC 10 ms
34,436 KB
testcase_10 AC 11 ms
34,496 KB
testcase_11 AC 11 ms
34,700 KB
testcase_12 AC 11 ms
34,568 KB
testcase_13 AC 12 ms
34,644 KB
testcase_14 AC 11 ms
34,628 KB
testcase_15 AC 12 ms
34,640 KB
testcase_16 AC 11 ms
34,732 KB
testcase_17 AC 12 ms
34,812 KB
testcase_18 AC 12 ms
35,088 KB
testcase_19 AC 12 ms
34,984 KB
testcase_20 AC 18 ms
39,084 KB
testcase_21 AC 18 ms
39,764 KB
testcase_22 AC 36 ms
50,552 KB
testcase_23 AC 77 ms
75,636 KB
testcase_24 AC 77 ms
76,400 KB
testcase_25 AC 18 ms
39,328 KB
testcase_26 AC 67 ms
70,656 KB
testcase_27 AC 28 ms
45,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int n;
int dp[4][1000001];

int func(int prev, int now)
{
  if ( now == n ) return 1;
  if( dp[prev][now] ) return dp[prev][now];

  int ret = 0;
  Rrep(i, 1, 4) {
    if( now + i <= n && prev != i ) ret += func(i, now + i);
  }

  return dp[prev][now] = ret % 1000000007;
}

signed main()
{
  cin >> n;
  
  fill_n(*dp, 4 * 1000001, 0);

  cout << (func(1, 1) + func(2, 2) + func(3, 3)) % 1000000007 << endl;
  return 0;
}
0