結果

問題 No.978 Fibonacci Convolution Easy
ユーザー karinohitokarinohito
提出日時 2021-09-06 00:00:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 166,136 KB
実行使用メモリ 19,552 KB
最終ジャッジ日時 2023-08-24 05:31:27
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 34 ms
10,084 KB
testcase_02 AC 18 ms
6,960 KB
testcase_03 AC 79 ms
18,772 KB
testcase_04 AC 22 ms
7,600 KB
testcase_05 AC 7 ms
4,500 KB
testcase_06 AC 30 ms
9,040 KB
testcase_07 AC 52 ms
13,612 KB
testcase_08 AC 37 ms
10,588 KB
testcase_09 AC 60 ms
14,964 KB
testcase_10 AC 81 ms
19,500 KB
testcase_11 AC 26 ms
8,168 KB
testcase_12 AC 6 ms
4,620 KB
testcase_13 AC 29 ms
9,040 KB
testcase_14 AC 10 ms
5,072 KB
testcase_15 AC 33 ms
9,732 KB
testcase_16 AC 81 ms
19,552 KB
testcase_17 AC 81 ms
19,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
ll mod=1e9+7;
vll DP(1e5+7,-1);

ll DF(ll M){
    if(DP[M]!=-1)return DP[M];
    ll res=0;
    for(ll i=1;i*i<=M;i++){
        if(M%i==0){
            res+=DF(M/i-1);
            res%=mod;
            if(M!=i*i){
                res+=DF(i-1);
            }
        }
    }    
    DP[M]=res;
    return res;
}
int main() {
    ll N,P;
    cin>>N>>P;
    vll A(N+3);
    A[0]=0,A[1]=1;
    ll S=0,D=0;
    rep(i,N-2){
        A[i+2]=A[i+1]*P+A[i];
        A[i+2]%=mod;
    }
    rep(i,N){
        S+=A[i];
        D+=A[i]*A[i];
        S%=mod;
        D%=mod;
    }
    ll AN=S*S;
    AN%=mod;
    AN+=D;
    AN+=mod;
    AN%=mod;
    AN*=(mod+1)/2;
    AN%=mod;
    cout<<AN<<endl;

}
0