結果

問題 No.533 Mysterious Stairs
ユーザー koba-e964koba-e964
提出日時 2017-06-23 23:12:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,015 bytes
コンパイル時間 816 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 26,720 KB
最終ジャッジ日時 2024-04-15 01:04:01
合計ジャッジ時間 1,723 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,496 KB
testcase_01 AC 2 ms
7,620 KB
testcase_02 AC 3 ms
7,620 KB
testcase_03 AC 3 ms
7,496 KB
testcase_04 AC 2 ms
7,496 KB
testcase_05 AC 2 ms
7,500 KB
testcase_06 AC 2 ms
7,496 KB
testcase_07 AC 2 ms
7,496 KB
testcase_08 AC 3 ms
7,496 KB
testcase_09 AC 3 ms
7,500 KB
testcase_10 AC 2 ms
7,492 KB
testcase_11 AC 3 ms
7,500 KB
testcase_12 AC 3 ms
7,500 KB
testcase_13 AC 2 ms
7,496 KB
testcase_14 AC 2 ms
7,496 KB
testcase_15 AC 3 ms
7,496 KB
testcase_16 AC 3 ms
7,496 KB
testcase_17 AC 2 ms
7,500 KB
testcase_18 AC 3 ms
7,620 KB
testcase_19 AC 3 ms
7,492 KB
testcase_20 AC 5 ms
10,340 KB
testcase_21 AC 6 ms
12,148 KB
testcase_22 AC 11 ms
16,708 KB
testcase_23 AC 26 ms
26,640 KB
testcase_24 AC 26 ms
26,720 KB
testcase_25 AC 6 ms
10,276 KB
testcase_26 AC 23 ms
26,264 KB
testcase_27 AC 9 ms
13,728 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