結果

問題 No.1350 2019-6problem
ユーザー kozykozy
提出日時 2021-01-17 13:10:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-29 13:39:17
合計ジャッジ時間 1,765 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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+=(x*A)//B
        x-=(x*A)//lcm(A,B)
        if x>K:
            kosu=x
            n=this*A
            sa=kosu-K
            if n%B==0:
                n-=B
            else:
                n-=n%B
            sa-=1
            n-=sa*B
            print(n)
            exit()
0