結果

問題 No.25 有限小数
ユーザー beetbeet
提出日時 2018-12-02 11:17:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 374 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 71,744 KB
最終ジャッジ日時 2023-09-10 23:05:13
合計ジャッジ時間 4,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,364 KB
testcase_01 AC 73 ms
71,300 KB
testcase_02 AC 71 ms
71,368 KB
testcase_03 AC 70 ms
71,364 KB
testcase_04 AC 72 ms
71,576 KB
testcase_05 AC 71 ms
71,296 KB
testcase_06 AC 70 ms
71,500 KB
testcase_07 AC 71 ms
71,444 KB
testcase_08 AC 71 ms
71,584 KB
testcase_09 AC 69 ms
71,396 KB
testcase_10 AC 70 ms
71,388 KB
testcase_11 AC 71 ms
71,592 KB
testcase_12 AC 69 ms
71,584 KB
testcase_13 AC 71 ms
71,444 KB
testcase_14 AC 72 ms
71,720 KB
testcase_15 AC 73 ms
71,472 KB
testcase_16 AC 72 ms
71,744 KB
testcase_17 AC 72 ms
71,236 KB
testcase_18 AC 73 ms
71,448 KB
testcase_19 AC 72 ms
71,364 KB
testcase_20 AC 71 ms
71,364 KB
testcase_21 AC 72 ms
71,584 KB
testcase_22 AC 70 ms
71,588 KB
testcase_23 AC 71 ms
71,728 KB
testcase_24 AC 71 ms
71,464 KB
testcase_25 AC 71 ms
71,280 KB
testcase_26 AC 71 ms
71,236 KB
testcase_27 AC 71 ms
71,468 KB
testcase_28 AC 69 ms
71,424 KB
testcase_29 AC 69 ms
71,564 KB
testcase_30 AC 70 ms
71,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n = int(input())
m = int(input())

k = math.gcd(n, m)
n = n // k
m = m // k

x = m
t = 0
f = 0

while x % 2 == 0:
    x = x // 2
    t = t + 1

while x % 5 == 0:
    x = x // 5
    f = f + 1
    
while t < f:
    n *= 2
    m *= 2
    t += 1

while t > f:
    n *= 5
    m *= 5
    f += 1

while n % 10 == 0:
    n = n // 10
    
print(n % 10 if x == 1 else -1)
0