結果

問題 No.554 recurrence formula
ユーザー miku39kk
提出日時 2017-08-11 23:13:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 500 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 67,224 KB
実行使用メモリ 13,632 KB
最終ジャッジ日時 2024-10-12 21:47:52
合計ジャッジ時間 4,635 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 TLE * 1 -- * 1
権限があれば一括ダウンロードができます

ソースコード

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