結果

問題 No.314 ケンケンパ
ユーザー Fpga18Gansn1230
提出日時 2017-10-05 18:48:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 513 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 54,264 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-11-16 21:27:34
合計ジャッジ時間 1,229 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  long long int map[1000005]={0};
  map[0]=0;
  map[1]=1;
  map[2]=1;
  for(int i=1;i<N;i++){
    if(map[i]!=0){
      map[i+2]=(map[i+2]+map[i])%1000000007;
      map[i+3]=(map[i+3]+map[i])%1000000007;
    }
  }
//  for(int i=0;i<10;i++){
//    cout << map[i] << endl;
//  }
  long long int sum=0;
  if(N==1){
    sum=1;
  }else if(N==2){
    sum=2;
  }else{
    sum=(map[N-1]+map[N-2]+map[N-3])%1000000007;
  }
  cout << sum<< endl;
}
0