結果

問題 No.2526 Kth Not-divisible Number
ユーザー hiro1729hiro1729
提出日時 2023-11-03 21:38:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 624 ms / 2,000 ms
コード長 292 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 81,908 KB
実行使用メモリ 76,148 KB
最終ジャッジ日時 2023-11-03 21:38:15
合計ジャッジ時間 7,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,712 KB
testcase_01 AC 32 ms
53,712 KB
testcase_02 AC 32 ms
53,712 KB
testcase_03 AC 607 ms
76,140 KB
testcase_04 AC 580 ms
76,144 KB
testcase_05 AC 624 ms
76,148 KB
testcase_06 AC 593 ms
76,148 KB
testcase_07 AC 610 ms
76,140 KB
testcase_08 AC 565 ms
76,144 KB
testcase_09 AC 571 ms
76,148 KB
testcase_10 AC 583 ms
76,148 KB
testcase_11 AC 533 ms
76,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
for _ in range(int(input())):
	a, b, k = map(int, input().split())
	g = gcd(a, b)
	l = a // g * b
	le = 1
	ri = 1 << 63
	while le + 1 < ri:
		mi = (le + ri) // 2
		if mi - ((mi // a) + (mi // b) - (mi // l)) >= k:
			ri = mi
		else:
			le = mi
	print(ri if k != 1 else 1)
0