結果

問題 No.533 Mysterious Stairs
ユーザー koba-e964koba-e964
提出日時 2017-06-23 23:12:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 1,015 bytes
コンパイル時間 2,518 ms
コンパイル使用メモリ 85,184 KB
実行使用メモリ 26,772 KB
最終ジャッジ日時 2023-07-27 12:59:18
合計ジャッジ時間 2,048 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,548 KB
testcase_01 AC 3 ms
7,500 KB
testcase_02 AC 2 ms
7,500 KB
testcase_03 AC 2 ms
7,432 KB
testcase_04 AC 2 ms
7,648 KB
testcase_05 AC 2 ms
7,512 KB
testcase_06 AC 2 ms
7,532 KB
testcase_07 AC 2 ms
7,492 KB
testcase_08 AC 3 ms
7,452 KB
testcase_09 AC 2 ms
7,508 KB
testcase_10 AC 3 ms
7,492 KB
testcase_11 AC 2 ms
7,532 KB
testcase_12 AC 3 ms
7,432 KB
testcase_13 AC 3 ms
7,448 KB
testcase_14 AC 2 ms
7,464 KB
testcase_15 AC 3 ms
7,452 KB
testcase_16 AC 3 ms
7,504 KB
testcase_17 AC 3 ms
7,560 KB
testcase_18 AC 3 ms
7,544 KB
testcase_19 AC 3 ms
7,536 KB
testcase_20 AC 7 ms
12,424 KB
testcase_21 AC 6 ms
12,496 KB
testcase_22 AC 14 ms
19,708 KB
testcase_23 AC 28 ms
26,680 KB
testcase_24 AC 28 ms
26,772 KB
testcase_25 AC 6 ms
12,704 KB
testcase_26 AC 25 ms
25,948 KB
testcase_27 AC 10 ms
13,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 1e6 + 10;
ll dp[3][N];

int main(void){
  int n;
  cin >> n;
  REP(i, 1, n + 1) {
    REP(j, 0, 3) {
      ll tmp = 0;
      REP(k, 0, 3) {
	if (j != k && i > j + 1) {
	  tmp += dp[k][i - j - 1];
	}
      }
      if (i == j + 1) {
	tmp += 1;
      }
      dp[j][i] = tmp % mod;
    }
  }
  ll tot = 0;
  REP(i, 0, 3) {
    tot = (tot + dp[i][n]) % mod;
  }
  cout << tot << endl;
}
0