結果

問題 No.2132 1 or X Game
ユーザー nok0
提出日時 2022-10-29 14:01:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 596 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 193,188 KB
最終ジャッジ日時 2025-02-08 15:44:29
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

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