結果

問題 No.314 ケンケンパ
ユーザー monnumonnu
提出日時 2020-09-30 20:45:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 454 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 168,340 KB
実行使用メモリ 57,864 KB
最終ジャッジ日時 2023-09-20 16:12:29
合計ジャッジ時間 3,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
56,564 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 9 ms
8,568 KB
testcase_18 AC 39 ms
28,988 KB
testcase_19 AC 79 ms
57,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000000000000
#define MOD 1000000007
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  vector<vector<ll>> dp(N,vector<ll>(3,0));
  dp[0][1]=1;
  for(int i=1;i<N;i++){
    dp[i][0]=dp[i-1][1]+dp[i-1][2];
    dp[i][0]%=MOD;
    dp[i][1]=dp[i-1][0];
    dp[i][2]=dp[i-1][1];
  }

  ll ans=dp[N-1][0]+dp[N-1][1]+dp[N-1][2];
  ans%=MOD;
  cout<<ans<<endl;
}
0