結果

問題 No.314 ケンケンパ
ユーザー es__135es__135
提出日時 2018-06-16 17:35:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 1,372 ms
コンパイル使用メモリ 145,456 KB
実行使用メモリ 14,768 KB
最終ジャッジ日時 2023-09-13 06:08:38
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int mod =1000000007; 
int main(){
  int n;cin>>n;
  if(n==1){
    cout<<1<<endl;
    return 0;  
  }

  vector<int> kk(n+5),kp(n+5),pk(n+5);
  kk[2]=1,kp[2]=1,pk[2]=0;
  
  for(int i=2;i<n;++i){
    kk[i+1]=pk[i]%mod;
    kp[i+1]=(kk[i]%mod+pk[i]%mod)%mod;
    pk[i+1]=kp[i]%mod;
  }
  
  int ans=(kk[n]%mod+kp[n]%mod+pk[n]%mod)%mod;
  cout<<ans<<endl;
}

0