結果

問題 No.1305 Speak of the Devil
ユーザー 👑Zack Ni
提出日時 2020-12-02 04:32:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 158,592 KB
最終ジャッジ日時 2024-09-13 03:48:56
合計ジャッジ時間 6,195 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 3 WA * 12 TLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import argparse


def main():
    p, q = list(map(int,input().split()))

    p = float(p)
    q = float(q)
    w = pow(p, -1)
    t = pow(p, -1)
    x = p*p
    y = (p-1)
    ans = 0
    prevans = -1000
    i = 0
    while True:
        ans = w * (x - p * y - i*y ) 
        w = w * t
        x = x * p
        y = y * (p-1)
        i = i + 1
        if ans - prevans < 1e-3:
            break
        prevans = ans
    
    print(min(ans, q))

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('--file', dest='filename', default=None)
    args = parser.parse_args()
    if args.filename is not None:
        sys.stdin = open(args.filename)
    main()
0