結果

問題 No.2132 1 or X Game
ユーザー nok0nok0
提出日時 2022-10-29 14:01:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 479 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 1,792 ms
コンパイル使用メモリ 199,664 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 13:02:39
合計ジャッジ時間 10,348 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 467 ms
5,376 KB
testcase_02 AC 479 ms
5,376 KB
testcase_03 AC 376 ms
5,376 KB
testcase_04 AC 460 ms
5,376 KB
testcase_05 AC 459 ms
5,376 KB
testcase_06 AC 457 ms
5,376 KB
testcase_07 AC 463 ms
5,376 KB
testcase_08 AC 463 ms
5,376 KB
testcase_09 AC 307 ms
5,376 KB
testcase_10 AC 414 ms
5,376 KB
testcase_11 AC 422 ms
5,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