結果

問題 No.2526 Kth Not-divisible Number
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-11-03 21:33:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 363 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 14,540 KB
最終ジャッジ日時 2023-11-03 21:33:33
合計ジャッジ時間 4,311 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
T = int(input())
for _ in range(T) :
	a, b, k = map(int, input().split())
	L = math.lcm(a, b)
	num = L - (L // a) - (L // b) + 1
	ans1 = k // num
	k %= num
	k += 1
	ok = L - 1
	ng = 0
	while abs(ok - ng) > 1 :
		md = (ok + ng) // 2
		nn = (md + 1) - (md // a + 1) - (md // b + 1) + 1
		if nn >= k :
			ok = md
		else :
			ng = md
	print(ans1 * L + ok)
0