結果

問題 No.314 ケンケンパ
ユーザー Fpga18Gansn1230Fpga18Gansn1230
提出日時 2017-10-05 18:48:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 513 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 54,652 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-28 07:50:53
合計ジャッジ時間 1,165 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,136 KB
testcase_01 AC 5 ms
11,264 KB
testcase_02 AC 6 ms
11,136 KB
testcase_03 AC 6 ms
11,136 KB
testcase_04 AC 6 ms
11,136 KB
testcase_05 AC 6 ms
11,136 KB
testcase_06 AC 5 ms
11,136 KB
testcase_07 AC 6 ms
11,136 KB
testcase_08 AC 5 ms
11,264 KB
testcase_09 AC 5 ms
11,264 KB
testcase_10 AC 6 ms
11,264 KB
testcase_11 AC 6 ms
11,136 KB
testcase_12 AC 5 ms
11,264 KB
testcase_13 AC 5 ms
11,264 KB
testcase_14 AC 5 ms
11,264 KB
testcase_15 AC 5 ms
11,136 KB
testcase_16 AC 6 ms
11,136 KB
testcase_17 AC 6 ms
11,264 KB
testcase_18 AC 8 ms
11,264 KB
testcase_19 AC 9 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

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