結果

問題 No.2526 Kth Not-divisible Number
ユーザー 👑 KA37RIKA37RI
提出日時 2023-11-03 22:07:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 454 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 10,204 KB
最終ジャッジ日時 2023-11-03 22:07:22
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from math import gcd
t = int(input())
for _ in range(t):
	ai, bi, ki = [int(x) for x in input().split()]
	li = ai // gcd(ai, bi) * bi
	left = 0
	right = 1
	while True:
		x = right - (right // ai) - (right // bi) + (right // li)
		if x > ki:
			left = right >> 2
			break
		right <<= 1
	while right - left > 1:
		mid = (right + left) // 2
		x = mid - (mid // ai) - (mid // bi) + (mid // li)
		if x >= ki:
			right = mid
		else:
			left = mid
	print(right)
0