結果
問題 |
No.554 recurrence formula
|
ユーザー |
|
提出日時 | 2017-12-01 00:56:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 471 bytes |
コンパイル時間 | 1,562 ms |
コンパイル使用メモリ | 163,028 KB |
実行使用メモリ | 5,328 KB |
最終ジャッジ日時 | 2024-11-27 15:38:05 |
合計ジャッジ時間 | 2,260 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; int main(void) { int n; cin >> n; vector<ll> a, cum[2]; a.push_back(1); cum[1].push_back(1); for (int i = 2; i <= n; i++) { ll aa = i * cum[(i + 1) & 1].back() % mod; a.push_back(aa); cum[i & 1].push_back(aa); if (cum[i & 1].size() > 1) { cum[i & 1].back() += cum[i & 1][(i - 1) / 2 - 1]; } } cout << a[n - 1] << endl; return 0; }