結果

問題 No.2132 1 or X Game
ユーザー nok0nok0
提出日時 2022-10-29 14:01:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 198,164 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 18:06:43
合計ジャッジ時間 11,936 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 525 ms
4,380 KB
testcase_02 AC 526 ms
4,376 KB
testcase_03 AC 440 ms
4,380 KB
testcase_04 AC 528 ms
4,380 KB
testcase_05 AC 520 ms
4,376 KB
testcase_06 AC 519 ms
4,376 KB
testcase_07 AC 517 ms
4,376 KB
testcase_08 AC 530 ms
4,380 KB
testcase_09 AC 355 ms
4,376 KB
testcase_10 AC 483 ms
4,376 KB
testcase_11 AC 466 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int mod = 998244353;

using ll = long long;

ll solve(ll n, ll x) {
	if(x & 1 or n < x) return (n + 1) / 2 % mod;
	//特殊なindex を削る
	//x,2x+3,3x+6,...
	ll sp = (n - x) / (x + 3) + 1;
	return ((n - sp + 1) / 2 + sp) % mod;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		ll n, x;
		cin >> n >> x;
		cout << solve(n, x) << '\n';
	}
}
0