結果

問題 No.25 有限小数
ユーザー aaaaaaaaaa2230
提出日時 2021-12-31 11:16:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 374 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 81,580 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-10-08 03:20:53
合計ジャッジ時間 2,444 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if n%m == 0:
    ans = n//m
    while ans%10 == 0:
        ans //= 10
    print(ans%10)
    exit()

two = 0
five = 0
nm = m
while m%5 == 0:
    m //= 5
    five += 1
while m%2 == 0:
    m //= 2
    two += 1

if m != 1:
    print(-1)
    exit()

n *= 5**two
n *= 2**five

ans = n
while ans%10 == 0:
    ans //= 10
print(ans%10)
0