結果
問題 |
No.554 recurrence formula
|
ユーザー |
![]() |
提出日時 | 2018-03-20 18:10:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 592 bytes |
コンパイル時間 | 712 ms |
コンパイル使用メモリ | 83,568 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 09:53:11 |
合計ジャッジ時間 | 1,508 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cstring> #include <math.h> #include <cmath> #include <limits.h> #include <map> #include <set> #include <queue> #include <algorithm> #include <functional> #include <stdio.h> using namespace std; long long MOD = 1000000007; int main() { int N; cin >> N; long long a[2]; a[0] = 0; a[1] = 1; for ( int i = 2; i < N; i++ ) { a[i%2] += (i*a[1-(i%2)])%MOD; a[i%2] %= MOD; } if ( N == 1 ) { cout << 1 << endl; } else { cout << (N*a[1-(N%2)])%MOD << endl; } return 0; }