結果

問題 No.2132 1 or X Game
ユーザー みここみここ
提出日時 2022-12-11 19:28:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 558 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 71,092 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 15:14:10
合計ジャッジ時間 9,310 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 530 ms
6,816 KB
testcase_02 AC 526 ms
6,944 KB
testcase_03 AC 445 ms
6,940 KB
testcase_04 AC 532 ms
6,940 KB
testcase_05 AC 538 ms
6,944 KB
testcase_06 AC 558 ms
6,940 KB
testcase_07 AC 515 ms
6,944 KB
testcase_08 AC 523 ms
6,940 KB
testcase_09 AC 364 ms
6,940 KB
testcase_10 AC 472 ms
6,944 KB
testcase_11 AC 467 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
        }
    }
}
0