結果

問題 No.2526 Kth Not-divisible Number
ユーザー 👑 p-adicp-adic
提出日時 2023-07-07 00:01:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 899 ms / 2,000 ms
コード長 228 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 76,268 KB
最終ジャッジ日時 2023-11-03 21:28:11
合計ジャッジ時間 6,874 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,672 KB
testcase_01 AC 30 ms
53,672 KB
testcase_02 AC 29 ms
53,672 KB
testcase_03 AC 465 ms
76,064 KB
testcase_04 AC 468 ms
76,064 KB
testcase_05 AC 473 ms
76,268 KB
testcase_06 AC 484 ms
76,064 KB
testcase_07 AC 506 ms
76,064 KB
testcase_08 AC 460 ms
76,072 KB
testcase_09 AC 899 ms
76,160 KB
testcase_10 AC 522 ms
76,060 KB
testcase_11 AC 281 ms
76,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

I=input
for t in range(int(I())):
	A,B,K=map(int,I().split())
	C,D=A,B
	if A>B:C,D=D,C
	while C:C,D=D%C,C
	C=A*B//D
	N=int((K+1)/(1-1/A-1/B+1/C))
	while N-N//A-N//B+N//C>=K:N-=1
	while N-N//A-N//B+N//C<K:N+=1
	print(N)
0