結果

問題 No.533 Mysterious Stairs
ユーザー koba-e964
提出日時 2017-06-23 23:12:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 1,015 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 87,416 KB
実行使用メモリ 26,904 KB
最終ジャッジ日時 2024-10-04 07:57:40
合計ジャッジ時間 1,803 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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