結果
問題 |
No.554 recurrence formula
|
ユーザー |
![]() |
提出日時 | 2018-04-01 23:43:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 674 bytes |
コンパイル時間 | 531 ms |
コンパイル使用メモリ | 64,000 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 06:12:53 |
合計ジャッジ時間 | 1,392 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
// No.554 recurrence formula // https://yukicoder.me/problems/no/554 // #include <iostream> using namespace std; long long int solve(int n); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int n; cin >> n; long long ans = solve(n); cout << ans << endl; } long long int solve(int n) { long long ans = 1; long long odd_sum = 1; long long even_sum = 0; for (int i = 2; i <= n; ++i) { if (i % 2 == 0) { ans = i * odd_sum % 1000000007; even_sum += ans; } else { ans = i * even_sum % 1000000007; odd_sum += ans; } } return ans; }