結果

問題 No.554 recurrence formula
ユーザー miku39kkmiku39kk
提出日時 2017-08-11 23:13:39
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 500 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 66,716 KB
実行使用メモリ 10,528 KB
最終ジャッジ日時 2024-04-20 23:29:08
合計ジャッジ時間 4,787 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int n,p = 1000000007;
    cin >> n;
    vector<int> a;
    a.push_back(0);
    a.push_back(1);
    a.push_back(2);
    for(int i = 3;i <= n;i++){
        long long b = 0;
        for(int j = i%2+1;j < i;j+=2){
            b += a[j];
            b %= p;
        }
        b *= i;
        b %= p;
        a.push_back(b);
    }
    cout << a[n] << endl;
    return 0;
}
0