結果
| 問題 | No.554 recurrence formula |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-08 11:08:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 448 bytes |
| コンパイル時間 | 2,443 ms |
| コンパイル使用メモリ | 192,984 KB |
| 最終ジャッジ日時 | 2025-01-05 02:42:19 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:22: warning: ‘a’ may be used uninitialized [-Wmaybe-uninitialized]
21 | if (n & 1) cout << a << endl;
| ^
main.cpp:11:7: note: ‘a’ was declared here
11 | int a, b;
| ^
main.cpp:22:16: warning: ‘b’ may be used uninitialized [-Wmaybe-uninitialized]
22 | else cout << b << endl;
| ^
main.cpp:11:10: note: ‘b’ was declared here
11 | int a, b;
| ^
ソースコード
#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;
}