結果
| 問題 |
No.978 Fibonacci Convolution Easy
|
| ユーザー |
tonegawa
|
| 提出日時 | 2020-02-01 00:32:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 986 bytes |
| コンパイル時間 | 771 ms |
| コンパイル使用メモリ | 94,948 KB |
| 実行使用メモリ | 34,432 KB |
| 最終ジャッジ日時 | 2024-09-18 21:03:51 |
| 合計ジャッジ時間 | 1,880 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
ll n, p;std::cin >> n >> p;
ll P = 1000000007;
vll a(n, 0), s(n, 0);
a[0] = 0, a[1] = 1;
rep(i, 2, n) a[i] = ((p*a[i-1])%P + a[i-2])%P;
re(i, n) s[i] = ((i==0?0:s[i-1]) + a[i])%P;
ll ans = 0;
re(i, n){
ans = (ans + (a[i]*s[i])%P)%P;
}
std::cout << ans << '\n';
return 0;
}
tonegawa