結果
| 問題 |
No.980 Fibonacci Convolution Hard
|
| ユーザー |
kyort0n
|
| 提出日時 | 2020-01-31 22:21:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 344 ms / 2,000 ms |
| コード長 | 1,042 bytes |
| コンパイル時間 | 1,585 ms |
| コンパイル使用メモリ | 166,840 KB |
| 実行使用メモリ | 34,764 KB |
| 最終ジャッジ日時 | 2024-09-17 11:31:02 |
| 合計ジャッジ時間 | 9,712 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
template<class T>
inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const ll mod = 1000000007;
ll p;
ll P[2000100];
ll a[2000010];
int main() {
//cout.precision(10);
cin.tie(0);
ios::sync_with_stdio(false);
cin >> p;
a[2] = 1;
for(int i = 3; i <= 2e6; i++) {
a[i] = p * a[i-1] + a[i-2];
a[i] %= mod;
}
P[1] = 0;
P[2] = 0;
P[3] = 0;
P[4] = 1;
for(int i = 5; i <= 2e6; i++) {
P[i] = P[i-1] * p + P[i-2] + a[i-2];
P[i] %= mod;
}
int Q;
cin >> Q;
while(Q--) {
int q;
cin >> q;
cout << P[q] << endl;
}
return 0;
}
kyort0n