結果

問題 No.314 ケンケンパ
ユーザー kpinkcatkpinkcat
提出日時 2023-11-13 02:34:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 1,000 ms
コード長 712 bytes
コンパイル時間 2,320 ms
コンパイル使用メモリ 203,672 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2023-11-13 02:34:36
合計ジャッジ時間 4,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main()
{
    ll n;
    vector<ll> paken(1e6+1), pakenken(1e6+1), pa(1e6+1);
    cin >> n;
    paken[0] = 0;
    paken[1] = 1;
    pa[0] = 0;
    pa[1] = 0;
    pakenken[0] = 0;
    pakenken[1] = 0;
    for (int i = 2; i < 1e6+1; i++){
        pa[i] = (paken[i-1] + pakenken[i-1])%(1000000000+7);
        paken[i] = (pa[i-1])%(1000000000+7);
        pakenken[i] = (paken[i-1])%(1000000000+7);
    }
    cout << (pa[n] + paken[n] + pakenken[n])%(1000000000+7) << endl;
}
0