結果

問題 No.554 recurrence formula
ユーザー miku39kkmiku39kk
提出日時 2017-08-11 23:03:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 494 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 67,064 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-20 23:23:40
合計ジャッジ時間 4,510 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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++){
        int 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