結果

問題 No.978 Fibonacci Convolution Easy
ユーザー kotatsugame
提出日時 2020-02-02 03:49:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 63,232 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 21:07:20
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
long p,mod=1e9+7;
long a=1,b=0,s=1,ans=1;
main()
{
	cin>>N>>p;
	if(N==1)
	{
		cout<<0<<endl;
		return 0;
	}
	for(int i=2;i<N;i++)
	{
		long c=(a*p+b)%mod;
		(s+=c)%=mod;
		(ans+=s*c%mod)%=mod;
		b=a;a=c;
	}
	cout<<ans<<endl;
}
0