結果

問題 No.1350 2019-6problem
ユーザー maninimanini
提出日時 2021-01-22 13:18:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 51,968 KB
最終ジャッジ日時 2024-12-26 11:12:54
合計ジャッジ時間 1,962 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:UTF-8
import sys

MOD = 10 ** 9 + 7
INF = float('inf')


# 約数 倍数
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    d = gcd(a, b)
    return int(a / d * b)


A, B, K = list(map(int, input().split()))     # スペース区切り連続数字
C = lcm(A, B)

# 二分探索
imin = 0
imax = A * (K + 1)
while imax - imin > 1:
    imid = imin + (imax - imin) // 2

    check = imid // A + imid // B - imid // C

    # 2分探索する。
    if check <= K:
        imin = imid
    else:
        imax = imid

res = max(A * (imin // A), B * (imin // B))

print("{}".format(res))
0