結果

問題 No.1350 2019-6problem
ユーザー kozykozy
提出日時 2021-01-17 13:19:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 8,456 KB
最終ジャッジ日時 2023-08-19 18:54:13
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,236 KB
testcase_01 AC 15 ms
8,256 KB
testcase_02 AC 15 ms
8,248 KB
testcase_03 AC 15 ms
8,236 KB
testcase_04 AC 15 ms
8,316 KB
testcase_05 AC 15 ms
8,324 KB
testcase_06 AC 14 ms
8,436 KB
testcase_07 AC 15 ms
8,400 KB
testcase_08 AC 15 ms
8,456 KB
testcase_09 AC 15 ms
8,252 KB
testcase_10 AC 15 ms
8,256 KB
testcase_11 AC 16 ms
8,264 KB
testcase_12 AC 16 ms
8,392 KB
testcase_13 AC 15 ms
8,324 KB
testcase_14 AC 16 ms
8,408 KB
testcase_15 AC 15 ms
8,252 KB
testcase_16 AC 15 ms
8,256 KB
testcase_17 AC 15 ms
8,344 KB
testcase_18 AC 16 ms
8,384 KB
testcase_19 AC 15 ms
8,244 KB
testcase_20 AC 15 ms
8,404 KB
testcase_21 AC 15 ms
8,316 KB
testcase_22 AC 15 ms
8,248 KB
testcase_23 AC 15 ms
8,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def lcm(a,b):
    return a*b//(math.gcd(a,b))
A,B,K=map(int,input().split())
#Aの個数で2分探索
sita=0
ue=K
for i in range(100):
    this=(sita+ue)//2
    x=this
    x+=(this*A)//B
    x-=(this*A)//lcm(A,B)
    if x==K:
        print(A*this)
        exit()
    elif x>K:
        ue=(sita+ue)//2
    else:#x<K
        sita=(sita+ue)//2
        x=(this+1)
        x+=((this+1)*A)//B
        x-=((this+1)*A)//lcm(A,B)
        if x==K:
            print((this+1)*A)
            exit()
        if x>K:
            kosu=x
            n=(this+1)*A
            sa=kosu-K
            if n%B==0:
                n-=B
            else:
                n-=n%B
            sa-=1
            n-=sa*B
            print(n)
            exit()
0