結果

問題 No.194 フィボナッチ数列の理解(1)
ユーザー tkzw_21tkzw_21
提出日時 2015-04-26 23:00:54
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 506 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 146,164 KB
実行使用メモリ 98,788 KB
最終ジャッジ日時 2023-09-18 09:01:12
合計ジャッジ時間 6,313 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const int MOD = 1e9+7;

int main(void){
	int n,k;
	cin >> n >> k;
	vector<ll> a(k+1);
	vector<ll> s(k+1);

	for(int i=0;i<n;i++){
		cin >> a[i];
		s[i] = a[i];
	}
	for(int i=1;i<n;i++){
		s[i] += s[i-1];
	}
	a[n] = s[n-1];
	s[n] = s[n-1] + a[n];

	for(int i=n+1;i<k;i++){
		a[i] += s[i-1] - s[i-n-1];
		s[i] = s[i-1] + a[i];
		a[i] %= MOD;
		s[i] %= MOD;
	}

	cout << a[k-1] << " " << s[k-1] << endl;
	return 0;
}
0