結果
| 問題 |
No.978 Fibonacci Convolution Easy
|
| ユーザー |
totori_nyaa
|
| 提出日時 | 2020-01-31 21:39:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 607 bytes |
| コンパイル時間 | 1,413 ms |
| コンパイル使用メモリ | 166,652 KB |
| 実行使用メモリ | 19,168 KB |
| 最終ジャッジ日時 | 2024-09-18 20:52:06 |
| 合計ジャッジ時間 | 2,394 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[2000010];
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
ll n,p;
cin>>n>>p;
ll mod = 1e9+7;
a[0]=0,a[1]=1;
for(int i=2;i<n;i++){
a[i] = (p*a[i-1])%mod + a[i-2];
a[i] %= mod;
}
ll ans = 0;
ll sum = 0;
for(int i=0;i<n;i++){
sum += a[i];
sum %= mod;
}
for(int i=0;i<n;i++){
ans += (sum * a[i])%mod;
sum += mod - a[i];
ans %= mod;
sum %= mod;
}
cout << ans << endl;
}
totori_nyaa