結果

問題 No.978 Fibonacci Convolution Easy
ユーザー Apppp11Apppp11
提出日時 2020-02-01 02:26:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 67,260 KB
実行使用メモリ 19,308 KB
最終ジャッジ日時 2023-10-17 23:45:00
合計ジャッジ時間 2,604 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 9 ms
8,404 KB
testcase_03 WA -
testcase_04 AC 11 ms
8,404 KB
testcase_05 AC 5 ms
6,356 KB
testcase_06 WA -
testcase_07 AC 23 ms
14,548 KB
testcase_08 AC 16 ms
10,452 KB
testcase_09 AC 26 ms
16,596 KB
testcase_10 WA -
testcase_11 AC 11 ms
8,404 KB
testcase_12 AC 4 ms
6,356 KB
testcase_13 WA -
testcase_14 AC 5 ms
6,356 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 35 ms
19,216 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 <iostream>
#include <algorithm>
using namespace std;

    long long a[2000000],p,n,sum=0,expsum=0;
    const long long MOD=1000000007;
    bool oe=false;

long long llmod(long long x){
    oe=(oe^((x/MOD)%2));
    return x%MOD;
}
int main(void){
    // Your code here!
    cin>>n>>p;
    for(long long i=0;i<n;i++){
        if(i<2)a[i]=i;
        else a[i]=llmod(llmod(a[i-1]*p)+a[i-2]);
        sum=llmod(sum+a[i]);
        expsum=llmod(expsum+llmod(a[i]*a[i]));
    }
    cout<<llmod((llmod(llmod(sum*sum)+expsum)+(oe?MOD:0))/2)<<endl;
    return 0;
}
0