結果

問題 No.533 Mysterious Stairs
ユーザー h_nosonh_noson
提出日時 2017-07-11 01:13:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 855 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 93,304 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2024-04-16 16:30:19
合計ジャッジ時間 2,014 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 7 ms
6,944 KB
testcase_21 AC 7 ms
6,940 KB
testcase_22 AC 17 ms
9,600 KB
testcase_23 AC 41 ms
19,072 KB
testcase_24 AC 41 ms
19,072 KB
testcase_25 AC 7 ms
6,948 KB
testcase_26 AC 36 ms
17,024 KB
testcase_27 AC 12 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int MOD = 1e9+7;

int dp[1000002][4];

int main(void) {
    int i, j, k, n;
    cin >> n;
    dp[0][0] = 1;
    REP (i,n) REP (j,4) REP (k,1,3) if (j != k) dp[i+k][k] = (dp[i+k][k] + dp[i][j]) % MOD;
    int ans = 0;
    REP (j,1,3) ans = (ans + dp[n][j]) % MOD;
    cout << ans << endl;
    return 0;
}
0