結果

問題 No.314 ケンケンパ
ユーザー knkknk
提出日時 2017-09-17 17:41:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 583 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 163,340 KB
実行使用メモリ 27,000 KB
最終ジャッジ日時 2024-04-25 14:58:14
合計ジャッジ時間 2,282 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
26,452 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 4 ms
6,940 KB
testcase_18 AC 6 ms
14,636 KB
testcase_19 AC 9 ms
27,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n;
  cin >> n;
  ll dp[n][3];
  dp[0][0] = 0; dp[0][1] = 1; dp[0][2] = 0;
  for (ll i = 1; i < n; ++i) {
    dp[i][0] = dp[i-1][1] + dp[i-1][2];
    dp[i][1] = dp[i-1][0];
    dp[i][2] = dp[i-1][1];
    dp[i][0] %= 1000000007;
    dp[i][1] %= 1000000007;
    dp[i][2] %= 1000000007;
  }
  cout << (dp[n-1][0] + dp[n-1][1] + dp[n-1][2])%1000000007 << endl;
  return 0;
}
0