結果

問題 No.554 recurrence formula
ユーザー 0w10w1
提出日時 2017-09-08 11:08:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 1,935 ms
コンパイル使用メモリ 199,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 01:41:57
合計ジャッジ時間 3,076 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:22:16: 警告: ‘b’ may be used uninitialized [-Wmaybe-uninitialized]
   22 |   else cout << b << endl;
      |                ^
main.cpp:11:10: 備考: ‘b’ はここで定義されています
   11 |   int a, b;
      |          ^
main.cpp:21:22: 警告: ‘a’ may be used uninitialized [-Wmaybe-uninitialized]
   21 |   if (n & 1) cout << a << endl;
      |                      ^
main.cpp:11:7: 備考: ‘a’ はここで定義されています
   11 |   int a, b;
      |       ^

ソースコード

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;
  int a, b;
  for (int i = 2; i <= n; ++i) {
    if (i & 1) {
      a = 1LL * i * even % MOD;
      odd = (odd + a) % MOD;
    } else {
      b = 1LL * i * odd % MOD;
      even = (even + b) % MOD;
    }
  }
  if (n & 1) cout << a << endl;
  else cout << b << endl;
  return 0;
}
0