結果

問題 No.25 有限小数
ユーザー kohei2019kohei2019
提出日時 2021-02-10 12:39:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 71,696 KB
最終ジャッジ日時 2023-09-22 06:29:07
合計ジャッジ時間 3,866 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,264 KB
testcase_01 AC 74 ms
71,476 KB
testcase_02 AC 71 ms
71,540 KB
testcase_03 AC 71 ms
71,180 KB
testcase_04 AC 71 ms
71,272 KB
testcase_05 AC 72 ms
71,452 KB
testcase_06 AC 70 ms
71,084 KB
testcase_07 AC 71 ms
71,084 KB
testcase_08 AC 71 ms
71,260 KB
testcase_09 AC 71 ms
71,088 KB
testcase_10 AC 71 ms
71,480 KB
testcase_11 AC 71 ms
71,532 KB
testcase_12 WA -
testcase_13 AC 72 ms
71,300 KB
testcase_14 AC 72 ms
71,544 KB
testcase_15 AC 72 ms
71,324 KB
testcase_16 AC 71 ms
71,540 KB
testcase_17 AC 72 ms
71,288 KB
testcase_18 AC 72 ms
71,480 KB
testcase_19 AC 71 ms
71,268 KB
testcase_20 AC 71 ms
71,480 KB
testcase_21 AC 72 ms
71,440 KB
testcase_22 AC 71 ms
71,216 KB
testcase_23 AC 71 ms
71,256 KB
testcase_24 AC 71 ms
71,540 KB
testcase_25 AC 70 ms
71,544 KB
testcase_26 AC 70 ms
71,264 KB
testcase_27 AC 70 ms
71,268 KB
testcase_28 AC 70 ms
71,440 KB
testcase_29 AC 71 ms
71,256 KB
testcase_30 AC 71 ms
71,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys
N = int(input())
M = int(input())
gcd = math.gcd(N,M)
N1 = N//gcd
M1 = M//gcd
l2 = 0
while M1 % 2 == 0:
    l2 += 1
    M1 //= 2
l5 = 0
while M1 % 5 == 0:
    l5 += 1
    M1 //= 5
if M1 != 1:
    print(-1)
    sys.exit()
if l2 > l5:
    print(5)
elif l2 == l5:
    div = 10
    while N1%div == 0:
        N1 //= 10
    print(N1)
else:
    c5 = l5-l2
    while c5:
        N1 %= 5
        N1 *= 2
        c5 -= 1
    print(N1)
0