結果

問題 No.2132 1 or X Game
ユーザー nok0nok0
提出日時 2022-10-29 14:01:20
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.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
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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