結果

問題 No.1350 2019-6problem
ユーザー maninimanini
提出日時 2021-01-22 13:18:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 71,660 KB
最終ジャッジ日時 2023-08-27 03:45:13
合計ジャッジ時間 3,182 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,392 KB
testcase_01 AC 70 ms
71,620 KB
testcase_02 AC 72 ms
71,444 KB
testcase_03 AC 73 ms
71,584 KB
testcase_04 AC 74 ms
71,372 KB
testcase_05 AC 71 ms
71,236 KB
testcase_06 AC 70 ms
71,560 KB
testcase_07 AC 72 ms
71,540 KB
testcase_08 AC 72 ms
71,384 KB
testcase_09 AC 71 ms
71,328 KB
testcase_10 AC 70 ms
71,560 KB
testcase_11 AC 71 ms
71,264 KB
testcase_12 AC 71 ms
71,456 KB
testcase_13 AC 71 ms
71,652 KB
testcase_14 AC 73 ms
71,448 KB
testcase_15 AC 72 ms
71,368 KB
testcase_16 AC 70 ms
71,308 KB
testcase_17 AC 70 ms
71,328 KB
testcase_18 AC 70 ms
71,620 KB
testcase_19 AC 69 ms
71,300 KB
testcase_20 AC 69 ms
71,660 KB
testcase_21 AC 71 ms
71,368 KB
testcase_22 AC 71 ms
71,240 KB
testcase_23 AC 70 ms
71,388 KB
権限があれば一括ダウンロードができます

ソースコード

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