結果

問題 No.980 Fibonacci Convolution Hard
ユーザー leaf_1415
提出日時 2020-01-31 22:23:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 555 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 59,456 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-17 08:48:18
合計ジャッジ時間 5,112 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 RE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#define llint long long
#define mod 1000000007

using namespace std;

llint p, Q;
llint a[200005], f[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> p >> Q;
	
	a[2] = 1;
	for(int i = 3; i < 200005; i++) a[i] = p*a[i-1]%mod + a[i-2], a[i] %= mod;
	
	f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 1;
	for(int i = 5; i < 200005; i++){
		f[i] = p*f[i-1]%mod + f[i-2] + a[i-2], f[i] %= mod;
	}
	
	llint x;
	for(int q = 0; q < Q; q++){
		cin >> x;
		cout << f[x] << endl;
	}
	
	return 0;
}
0