結果

問題 No.2526 Kth Not-divisible Number
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-11-03 21:41:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 547 ms / 2,000 ms
コード長 431 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 76,128 KB
最終ジャッジ日時 2023-11-03 21:41:22
合計ジャッジ時間 5,743 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,760 KB
testcase_01 AC 35 ms
53,760 KB
testcase_02 AC 32 ms
53,760 KB
testcase_03 AC 499 ms
76,124 KB
testcase_04 AC 547 ms
76,120 KB
testcase_05 AC 522 ms
76,124 KB
testcase_06 AC 528 ms
76,124 KB
testcase_07 AC 500 ms
76,124 KB
testcase_08 AC 314 ms
76,124 KB
testcase_09 AC 327 ms
76,128 KB
testcase_10 AC 357 ms
76,124 KB
testcase_11 AC 299 ms
76,124 KB
権限があれば一括ダウンロードができます

ソースコード

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
	k -= 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(f"L : {L}, num : {num}, ans1 : {ans1}, ok : {ok}")
	print(ans1 * L + ok)
0