結果

問題 No.194 フィボナッチ数列の理解(1)
ユーザー koba-e964koba-e964
提出日時 2015-05-01 15:57:02
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,157 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 87,784 KB
実行使用メモリ 7,792 KB
最終ジャッジ日時 2023-09-19 04:51:45
合計ジャッジ時間 7,411 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;


const int N = 10010;
int a[N];
const int mod = 1e9 + 7;
int n, k;

/* k is small */
void small() {
  a[n] = 0;
  ll sum = 0;
  REP(i, 0, n) {
    a[n] += a[i];
  }
  sum = a[n] * 2 % mod;
  REP(i, n + 1, k) {
    int c = i % (n + 1);
    ll s = 2 * a[(i + n) % (n + 1)];
    s -= a[c];
    a[c] = s % mod;
    sum += a[c];
    sum %= mod;
  }
  cout << a[(k - 1) % (n + 1)] << " " << sum << endl;
}

void large() {
  small();
}

int main(void){
  cin >> n >> k;
  REP(i, 0, n) {
    cin >> a[i];
  }
  if (n >= 31) {
    small();
    return 0;
  }
  large();
}
0