結果

問題 No.25 有限小数
ユーザー ant2357
提出日時 2017-05-25 23:45:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 422 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-19 19:17:44
合計ジャッジ時間 1,861 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*
import math
n = int(input())
m = int(input())

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

while n % 10 == 0:
    n //= 10
n %= 10

lieSolution = 0
while m % 5 == 0:
    m //= 5
    n *= 2
    n %= 10
while m % 2 == 0:
    m //= 2
    n *= 5
    n %= 10
    if n == 0:
        lieSolution += 1

if m == 1:
    if lieSolution == 0:
        print(n)
    else:
        print(lieSolution)
else:
    print(-1)
0