結果

問題 No.978 Fibonacci Convolution Easy
ユーザー tarattata1tarattata1
提出日時 2019-08-06 06:41:12
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 861 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 73,960 KB
実行使用メモリ 13,288 KB
最終ジャッジ日時 2023-10-14 09:10:18
合計ジャッジ時間 6,371 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n, p;
    scanf("%d%d", &n, &p);

    vector<ll> a(n+1);
    ll sum=0;
    int i,j;
    for(i=1; i<=n; i++) {
        if(i==1) a[i]=0;
        else if(i==2) a[i]=1;
        else a[i]=(a[i-2]+p*a[i-1])%MOD;

        for(j=1; j<=i; j++) {
            sum = (sum+(a[i]*a[j]))%MOD;
        }
    }
    printf("%lld\n", sum);

    return 0;
}
0