結果

問題 No.314 ケンケンパ
コンテスト
ユーザー kano00
提出日時 2020-09-11 11:37:08
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 680 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,097 ms
コンパイル使用メモリ 181,448 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2026-05-31 08:58:27
合計ジャッジ時間 2,504 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;


int main(void){

    int N;
    cin>>N;

    vector<ll> dp(N,0);

    //Use dp, dp[i]=dp[i-2]+dp[i-3];
    dp[0]=1;
    dp[1]=2;
    dp[2]=2;

    FOR(i,3,N){
        dp[i]=dp[i-2]+dp[i-3];
        dp[i]%=MOD;
    }

    cout<<dp[N-1]<<endl;
    return 0;
}
0