結果
問題 |
No.554 recurrence formula
|
ユーザー |
|
提出日時 | 2019-01-19 04:38:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 393 bytes |
コンパイル時間 | 1,559 ms |
コンパイル使用メモリ | 168,076 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 18:41:35 |
合計ジャッジ時間 | 2,601 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); const int mod = 1e9 + 7; int n; cin >> n; vector<long long> a(n + 1), b(n + 1); a[1] = 1; b[1] = 1; for (int i = 2; i <= n; i++) { b[i] = i * a[i - 1]; a[i] = i * a[i - 1] + a[i - 2]; b[i] %= mod; a[i] %= mod; } cout << b[n] << endl; return 0; }