結果
| 問題 |
No.978 Fibonacci Convolution Easy
|
| ユーザー |
merom686
|
| 提出日時 | 2020-01-31 22:23:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 616 bytes |
| コンパイル時間 | 701 ms |
| コンパイル使用メモリ | 76,724 KB |
| 実行使用メモリ | 11,020 KB |
| 最終ジャッジ日時 | 2024-09-18 20:59:27 |
| 合計ジャッジ時間 | 1,623 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;
constexpr int P = 1000000007;
int main() {
int n, p;
cin >> n >> p;
vector<int> a(n);
a[0] = 0;
a[1] = 1;
ll s = a[0] + a[1];
for (int i = 2; i < n; i++) {
s += a[i] = ((ll)p * a[i - 1] + a[i - 2]) % P;
}
s %= P;
ll r = 0;
for (int i = 0; i < n; i++) {
r += a[i] * s % P;
s -= a[i];
if (s < 0) s += P;
}
r %= P;
cout << r << endl;
return 0;
}
merom686