結果

問題 No.978 Fibonacci Convolution Easy
ユーザー Apppp11
提出日時 2020-02-01 02:26:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 67,352 KB
実行使用メモリ 19,104 KB
最終ジャッジ日時 2024-09-17 20:48:59
合計ジャッジ時間 1,570 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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