結果

問題 No.978 Fibonacci Convolution Easy
ユーザー ytftytft
提出日時 2021-04-17 13:49:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 418 bytes
コンパイル時間 1,283 ms
コンパイル使用メモリ 166,984 KB
実行使用メモリ 18,704 KB
最終ジャッジ日時 2023-09-16 22:38:55
合計ジャッジ時間 2,564 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 9 ms
8,932 KB
testcase_02 AC 5 ms
6,104 KB
testcase_03 AC 17 ms
17,844 KB
testcase_04 AC 7 ms
6,676 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 7 ms
8,208 KB
testcase_07 AC 12 ms
12,884 KB
testcase_08 AC 9 ms
9,872 KB
testcase_09 AC 13 ms
14,012 KB
testcase_10 AC 16 ms
18,636 KB
testcase_11 AC 7 ms
7,568 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 8 ms
8,220 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 8 ms
8,936 KB
testcase_16 AC 18 ms
18,632 KB
testcase_17 AC 18 ms
18,704 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,p;
    cin>>N>>p;
    long long MOD=1000000007;
    long long temp=0;
    vector<long long> a(N);
    long long ans=1,sum=1;
    a[1]=1;
    for(int i=2;i<N;++i){
        a[i]=(a[i-1]*p+a[i-2])%MOD;
        sum=(sum+a[i])%MOD;
        ans=(ans+a[i]*a[i])%MOD;
    }
    ans=(ans+sum*sum)%MOD;
    ans=(ans*500000004)%MOD;
    cout<<ans<<endl;
}
0