結果

問題 No.1350 2019-6problem
ユーザー 👑 H20H20
提出日時 2021-01-17 20:38:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 71,740 KB
最終ジャッジ日時 2023-08-20 02:40:00
合計ジャッジ時間 3,507 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,136 KB
testcase_01 AC 65 ms
71,492 KB
testcase_02 AC 63 ms
71,132 KB
testcase_03 AC 63 ms
71,300 KB
testcase_04 AC 64 ms
71,692 KB
testcase_05 AC 63 ms
71,444 KB
testcase_06 AC 61 ms
71,540 KB
testcase_07 AC 61 ms
71,444 KB
testcase_08 AC 64 ms
71,316 KB
testcase_09 AC 66 ms
71,732 KB
testcase_10 AC 64 ms
71,124 KB
testcase_11 AC 63 ms
71,276 KB
testcase_12 AC 63 ms
71,404 KB
testcase_13 AC 62 ms
71,132 KB
testcase_14 AC 65 ms
71,276 KB
testcase_15 AC 66 ms
71,488 KB
testcase_16 AC 63 ms
71,328 KB
testcase_17 AC 64 ms
71,740 KB
testcase_18 AC 64 ms
71,320 KB
testcase_19 AC 63 ms
71,416 KB
testcase_20 AC 65 ms
71,488 KB
testcase_21 AC 65 ms
71,264 KB
testcase_22 AC 65 ms
71,520 KB
testcase_23 AC 63 ms
71,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#めぐる式二部探索
#参考サイト:https://aotamasaki.hatenablog.com/entry/meguru_bisect
import math

A,B,K = map(int, input().split())
gclcm = (A * B) // math.gcd(A, B)


def is_ok(arg):
    # 整数を買えればTrueを返す
    return arg//A+arg//B-arg//gclcm<K

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(meguru_bisect(max(A,B)*K, 0)+1)
0