結果
問題 |
No.2526 Kth Not-divisible Number
|
ユーザー |
|
提出日時 | 2023-11-03 21:57:15 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 464 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 81,996 KB |
最終ジャッジ日時 | 2024-09-25 20:11:36 |
合計ジャッジ時間 | 12,780 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 5 |
ソースコード
import sys input = sys.stdin.readline from math import gcd def solve(): a,b,k = map(int,input().split()) ab = a*b//(gcd(a,b)) base = ab - ab//a - ab//b + 1 l = ab * (k-1)//base r = l + 2*ab while r - l > 1: m = (r+l)//2 num = m num -= m//a + m//b num += m//ab if num > k: r = m else: l = m return l t = int(input()) for _ in range(t): print(solve())