結果
| 問題 |
No.978 Fibonacci Convolution Easy
|
| ユーザー |
|
| 提出日時 | 2020-01-31 21:52:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 756 bytes |
| コンパイル時間 | 791 ms |
| コンパイル使用メモリ | 83,080 KB |
| 実行使用メモリ | 18,848 KB |
| 最終ジャッジ日時 | 2024-09-18 20:55:17 |
| 合計ジャッジ時間 | 1,700 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define endl "\n"
constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;
string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout<<fixed<<setprecision(10);
int N, p;
vector<int> a;
int sum = 0, ans = 0;
cin>>N>>p;
a.resize(N);
a[0] = 0;
a[1] = 1;
for(int i = 2; i < N; i++){
a[i] = a[i-1] * p + a[i-2];
a[i] %= MOD;
}
for(int i = 0; i < N; i++){
sum += a[i];
sum %= MOD;
ans += a[i] * sum;
ans %= MOD;
}
cout<<ans<<endl;
return 0;
}