結果

問題 No.314 ケンケンパ
ユーザー es__135es__135
提出日時 2018-06-16 17:37:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 20 ms / 1,000 ms
コード長 428 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 146,224 KB
実行使用メモリ 26,484 KB
最終ジャッジ日時 2023-09-13 06:08:45
合計ジャッジ時間 2,545 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
26,088 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 5 ms
5,420 KB
testcase_18 AC 12 ms
14,228 KB
testcase_19 AC 20 ms
26,484 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<long long 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;
  }
  
  long long int ans=(kk[n]%mod+kp[n]%mod+pk[n]%mod)%mod;
  cout<<ans<<endl;
}

0