結果
| 問題 |
No.980 Fibonacci Convolution Hard
|
| ユーザー |
りあん
|
| 提出日時 | 2020-01-31 22:15:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 539 bytes |
| コンパイル時間 | 1,958 ms |
| コンパイル使用メモリ | 194,916 KB |
| 最終ジャッジ日時 | 2025-01-08 21:13:12 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int p, q;
cin >> p >> q;
int n = 2000010;
vector<long long> a(n), s(n);
a[1] = 1;
for (int i = 2; i < n; i++) {
a[i] = (p * a[i - 1] + a[i - 2]) % M;
s[i] = ((p * s[i - 1] + s[i - 2] + a[i - 1]) % M + M) % M;
}
for (int i = 0; i < q; i++) {
int x;
cin >> x;
cout << s[x - 2] << '\n';
}
return 0;
}
りあん