結果
問題 |
No.2132 1 or X Game
|
ユーザー |
|
提出日時 | 2022-12-11 19:28:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 578 ms / 2,000 ms |
コード長 | 520 bytes |
コンパイル時間 | 664 ms |
コンパイル使用メモリ | 66,432 KB |
最終ジャッジ日時 | 2025-02-09 09:42:55 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
#include <iostream> using namespace std; typedef long long ll; const ll MOD = 998244353; int main() { int t; cin >> t; while (t--) { ll n, x; cin >> n >> x; if (x % 2 || n < x) { cout << (n + 1) / 2 % MOD << endl; } else { ll ans = x / 2; n -= x - 1; ans += n / (x + 3) * (x / 2 + 2); n %= x + 3; ans += (n + 1) / 2; cout << ans % MOD << endl; } } }