結果

問題 No.194 フィボナッチ数列の理解(1)
ユーザー alpha_virginisalpha_virginis
提出日時 2015-04-26 23:24:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 146,756 KB
実行使用メモリ 12,884 KB
最終ジャッジ日時 2023-09-18 11:09:04
合計ジャッジ時間 2,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 16 ms
12,756 KB
testcase_21 AC 18 ms
12,884 KB
testcase_22 AC 15 ms
11,272 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 10 ms
8,652 KB
testcase_25 AC 10 ms
8,456 KB
testcase_26 AC 10 ms
7,728 KB
testcase_27 AC 13 ms
12,164 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 15 ms
11,516 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main() {

  long N, K;

  std::cin >> N >> K;

  if( K <= 1000000 ) {

    std::vector<long> v;
    long num;
    long temp;
    long total;
    
    num = 0;
    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
      num += temp;
      num %= 1000000007;
    }

    total = num;
    for(int i = N; i < K; ++i) {
      v.push_back(num);
      total += num;
      total %= 1000000007;
      num *= 2;
      num += 1000000007;
      num -= v[i-N];
      num %= 1000000007;
    }

    std::cout << v[K-1]%1000000007 << " " << total << std::endl;
    return 0;
  }
  else {
    std::cout << 1 << " " << 1 << std::endl;
  }

  

  return 0;
}
0