結果
問題 | No.554 recurrence formula |
ユーザー |
![]() |
提出日時 | 2017-08-11 22:42:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 399 bytes |
コンパイル時間 | 1,568 ms |
コンパイル使用メモリ | 166,280 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 21:26:37 |
合計ジャッジ時間 | 2,262 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll MOD = ll(1e9 + 7);int main() {cin.tie(0);ios::sync_with_stdio(false);int n;cin >> n;ll odd = 1, even = 0, a = 1;for(int i = 2; i <= n; i++) {if(i % 2 == 0) {a = i * odd % MOD;even += a;even %= MOD;}else {a = i * even % MOD;odd += a;odd %= MOD;}}cout << a << endl;}