結果

問題 No.194 フィボナッチ数列の理解(1)
ユーザー alpha_virginis
提出日時 2015-04-26 23:24:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 1,273 ms
コンパイル使用メモリ 160,868 KB
実行使用メモリ 11,596 KB
最終ジャッジ日時 2024-07-05 02:17:49
合計ジャッジ時間 2,442 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 10 WA * 27
権限があれば一括ダウンロードができます

ソースコード

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