結果

問題 No.980 Fibonacci Convolution Hard
ユーザー tempura_pptempura_pp
提出日時 2020-01-30 02:03:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 809 bytes
コンパイル時間 787 ms
コンパイル使用メモリ 96,852 KB
実行使用メモリ 22,828 KB
最終ジャッジ日時 2023-10-14 08:03:03
合計ジャッジ時間 13,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 364 ms
22,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int main(){
    int M = 1234567;
    int p;
    cin>>p;
    vector<ll> ans(M),a(M);
    a[2]=1;
    for(int i=3;i<M;i++){
        ans[i]=(p*ans[i-1]+ans[i-2]+a[i-2])%mod;
        a[i]=(p*a[i-1]+a[i-2])%mod;
    }
    int q;
    cin>>q;
    rep(i,q){
        int x;
        cin>>x;
        cout<<ans[x]<<endl;
    }
    return 0;
}
0