結果

問題 No.314 ケンケンパ
ユーザー Min_25Min_25
提出日時 2015-12-07 09:26:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 680 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 62,932 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-12 19:50:22
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cassert>
#include <ctime>

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep3(i, m, n) for (int i = int(m); i < int(n); ++i)

using namespace std;
using uint64 = unsigned long long;
using uint32 = unsigned;

void solve() {
  const int MOD = 1e9 + 7;
  int N;
  while (~scanf("%d", &N)) {
    int p = 1;
    int k1 = 0;
    int k2 = 0;
    rep(i, N) {
      int t = p;
      p = (k1 + k2) % MOD;
      k2 = k1;
      k1 = t;
    }
    int ans = (uint64(p) + k2 + k1) % MOD;
    printf("%d\n", ans);
  }
}

int main() {
  solve();
  return 0;
}
0