結果
問題 | No.25 有限小数 |
ユーザー |
|
提出日時 | 2021-02-10 12:40:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 36 ms / 5,000 ms |
コード長 | 452 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 81,888 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-07-07 23:11:15 |
合計ジャッジ時間 | 1,942 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
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%10) else: c5 = l5-l2 while c5: N1 %= 5 N1 *= 2 c5 -= 1 print(N1)