結果

問題 No.25 有限小数
ユーザー mkawa2mkawa2
提出日時 2020-01-06 11:32:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,472 KB
最終ジャッジ日時 2024-05-02 10:46:25
合計ジャッジ時間 18,394 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 533 ms
43,956 KB
testcase_01 AC 533 ms
44,344 KB
testcase_02 AC 528 ms
44,340 KB
testcase_03 AC 536 ms
43,960 KB
testcase_04 AC 536 ms
43,832 KB
testcase_05 AC 533 ms
44,340 KB
testcase_06 AC 532 ms
43,960 KB
testcase_07 AC 532 ms
44,208 KB
testcase_08 AC 536 ms
44,472 KB
testcase_09 AC 533 ms
44,084 KB
testcase_10 AC 537 ms
44,216 KB
testcase_11 AC 533 ms
44,220 KB
testcase_12 AC 537 ms
44,216 KB
testcase_13 AC 536 ms
44,336 KB
testcase_14 AC 525 ms
43,956 KB
testcase_15 AC 531 ms
44,212 KB
testcase_16 AC 530 ms
44,216 KB
testcase_17 AC 533 ms
44,212 KB
testcase_18 AC 647 ms
44,216 KB
testcase_19 AC 530 ms
44,088 KB
testcase_20 AC 540 ms
44,212 KB
testcase_21 AC 534 ms
44,208 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 529 ms
43,956 KB
testcase_26 AC 528 ms
44,220 KB
testcase_27 AC 524 ms
44,088 KB
testcase_28 AC 535 ms
44,092 KB
testcase_29 AC 531 ms
43,968 KB
testcase_30 AC 525 ms
44,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
import numpy as np

def II(): return int(sys.stdin.readline())

def main():
    def lowest(a):
        a//=10
        a%=10
        print(a)
        exit()

    def cnt_factor(m):
        c2=c5=0
        while m&1==0:
            m>>=1
            c2+=1
        while m%5==0:
            m//=5
            c5+=1
        if m==1:return c2,c5
        return -1,-1

    n=II()
    m=II()
    g=np.gcd(m,n)
    n,m=n//g,m//g
    if m==1:lowest(n)
    c2,c5=cnt_factor(m)
    if c2==-1:print(-1)
    elif c2==c5:lowest(n)
    elif c2>c5:print(5)
    else:
        #/5=*0.2なのでc5回2をかけたときの最下位の数が答え
        c5-=c2
        n%=5
        print(pow(2,c5,10)*n%10)

main()
0