結果
問題 |
No.554 recurrence formula
|
ユーザー |
|
提出日時 | 2021-06-19 01:54:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 502 bytes |
コンパイル時間 | 1,698 ms |
コンパイル使用メモリ | 193,388 KB |
最終ジャッジ日時 | 2025-01-22 09:56:01 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long int a[100005]; const long long int MOD = 1e9 + 7; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; long long int odd = 1; long long int even = 0; a[1] = 1; for (int i = 2; i <= n; i++) { if (i % 2 == 0) { a[i] = i * odd; a[i] %= MOD; even += a[i]; even %= MOD; } else { a[i] = i * even; a[i] %= MOD; odd += a[i]; odd %= MOD; } } cout << a[n] << '\n'; return 0; }