結果

問題 No.533 Mysterious Stairs
ユーザー TatsunoTatsuno
提出日時 2017-06-23 23:04:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 2,020 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 162,428 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-04-15 01:00:19
合計ジャッジ時間 2,434 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 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,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 7 ms
7,040 KB
testcase_21 AC 7 ms
7,296 KB
testcase_22 AC 20 ms
15,360 KB
testcase_23 AC 50 ms
34,304 KB
testcase_24 AC 50 ms
34,688 KB
testcase_25 AC 7 ms
6,940 KB
testcase_26 AC 43 ms
30,464 KB
testcase_27 AC 13 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
using u32 = unsigned int; using u64 = unsigned long long int;
template <typename T> using vec = vector<T>;
void in() {}; template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); };
template <typename T> void _out(const char *sep, const char *end, T &&x) { cout << x << end; };
template <typename T, typename...TS> void _out(const char *sep, const char *end, T &&x, TS &&...xs) { cout << x << sep; _out(sep, end, move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t _; cin >> _; return _; }()
#define put(...) _out("", "", __VA_ARGS__)
#define out(...) _out(" ", "\n", __VA_ARGS__)
#define times(n, i) for (i32 i =  0 ; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i32 n;
i64 dp[1000001][4];

i32 main()
{
    ios::sync_with_stdio(false);

    in(n);
    dp[1][1] = 1;
    dp[2][2] = 1;
    dp[3][1] = 1;
    dp[3][2] = 1;
    dp[3][3] = 1;
    upto(4, n, ni) {
        upto(1, 3, si) {
            if (ni - si >= 0) {
                upto(1, 3, sj) {
                    if (si == sj) continue;
                    dp[ni][si] = (dp[ni][si] + dp[ni-si][sj]) % MOD;
                }
            }
        }
    }
    i64 ans = 0;
    upto(1, 3, si) {
        ans = (ans + dp[n][si]) % MOD;
    }
    out(ans);

    return 0;
}
0