結果

問題 No.978 Fibonacci Convolution Easy
ユーザー chocoruskchocorusk
提出日時 2020-01-31 21:43:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 995 ms
コンパイル使用メモリ 109,344 KB
実行使用メモリ 19,280 KB
最終ジャッジ日時 2023-10-19 00:59:27
合計ジャッジ時間 1,980 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 12 ms
11,100 KB
testcase_02 AC 7 ms
7,004 KB
testcase_03 AC 26 ms
18,648 KB
testcase_04 AC 9 ms
9,052 KB
testcase_05 AC 4 ms
4,464 KB
testcase_06 AC 11 ms
9,052 KB
testcase_07 AC 18 ms
15,196 KB
testcase_08 AC 14 ms
11,100 KB
testcase_09 AC 20 ms
15,196 KB
testcase_10 AC 28 ms
19,256 KB
testcase_11 AC 10 ms
9,052 KB
testcase_12 AC 4 ms
4,372 KB
testcase_13 AC 10 ms
9,052 KB
testcase_14 AC 6 ms
7,004 KB
testcase_15 AC 12 ms
11,100 KB
testcase_16 AC 28 ms
19,280 KB
testcase_17 AC 28 ms
19,240 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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