結果

問題 No.978 Fibonacci Convolution Easy
ユーザー chocorusk
提出日時 2020-01-31 21:43:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 908 ms
コンパイル使用メモリ 109,532 KB
実行使用メモリ 19,080 KB
最終ジャッジ日時 2024-09-18 20:54:18
合計ジャッジ時間 1,847 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n;
	ll p;
	cin>>n>>p;
	ll a[2000020];
	a[1]=0, a[2]=1;
	for(int i=3; i<=n; i++){
		a[i]=(p*a[i-1]+a[i-2])%MOD;
	}
	ll s=0, ans=0;
	for(int i=1; i<=n; i++){
		(s+=a[i])%=MOD;
		(ans+=s*a[i])%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0