結果

問題 No.554 recurrence formula
ユーザー aaaaaaiu
提出日時 2019-08-18 12:48:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 193,552 KB
最終ジャッジ日時 2025-01-07 14:10:24
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int m=1e9+7;
    int n;
    cin>>n;
    ll osum=1;
    ll esum=0;
    int a[n+1];
    a[1]=1;
    for (int i=2;i<=n;i++) {
        if (i%2==0) {
            a[i]=osum*i%m;
            esum=esum+a[i]%m;
        } else {
            a[i]=esum*i%m;
            osum=osum+a[i]%m;
        }
    }
    cout<<a[n]<<endl;
    return 0;
}
0