結果

問題 No.554 recurrence formula
ユーザー 0w1
提出日時 2017-09-08 11:06:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 403 bytes
コンパイル時間 1,977 ms
コンパイル使用メモリ 192,500 KB
最終ジャッジ日時 2025-01-05 02:42:09
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int MOD = int(1e9) + 7;

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int odd = 1, even = 0;
  for (int i = 2; i <= n; ++i) {
    if (i & 1) {
      odd = (odd + 1LL * i * even) % MOD;
    } else {
      even = (even + 1LL * i * odd) % MOD;
    }
  }
  if (n & 1) cout << odd << endl;
  else cout << even << endl;
  return 0;
}
0