結果

問題 No.314 ケンケンパ
ユーザー hokutohokuto
提出日時 2021-08-31 09:03:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 818 bytes
コンパイル時間 5,254 ms
コンパイル使用メモリ 95,456 KB
実行使用メモリ 57,808 KB
最終ジャッジ日時 2023-08-16 12:30:34
合計ジャッジ時間 2,512 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
56,720 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 4 ms
4,432 KB
testcase_17 AC 12 ms
8,496 KB
testcase_18 AC 43 ms
29,020 KB
testcase_19 AC 91 ms
57,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
using namespace std;
using ll = long long int;
#define chmax(x,y)  x = (x > (y)) ? x : (x = (y));
#define chmin(x,y)  x = (x < (y)) ? x : (x = (y));


int main(int argc, char const *argv[])
{
  int N; cin >> N;
  constexpr int Mod = 1e9 + 7;
  vector<vector<ll>> dp(N+1,vector<ll>(3));
  dp[0][0] = 1;
  for(int i=0;i<N;++i)
  {
    (dp[i+1][2] += dp[i][0]%Mod) %= Mod;
    (dp[i+1][1] += dp[i][0]%Mod) %= Mod;

    (dp[i+1][2] += dp[i][1]%Mod) %= Mod;

    (dp[i+1][0] += dp[i][2]%Mod) %= Mod;
  }
  ll answer = dp[N-1][0]%Mod + dp[N-1][1]%Mod + dp[N-1][2]%Mod;
  answer %= Mod;
  std::cout << answer << std::endl;
}
0