結果
問題 | No.25 有限小数 |
ユーザー |
|
提出日時 | 2020-05-01 18:50:03 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 763 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 21,504 KB |
最終ジャッジ日時 | 2024-12-24 14:15:19 |
合計ジャッジ時間 | 63,991 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 3 TLE * 9 |
ソースコード
N, M = int(input()), int(input())def to_and_five(num, lists=[]):if num == 1:return listsif num % 2 == 0:return to_and_five(num // 2, lists + [2])if num % 5 == 0:return to_and_five(num // 5, lists + [5])return Falsedef prime(n, m):for i in range(2, int(min(m, n) ** 0.5) + 1):if n % i == 0 and m % i == 0:return prime(n // i, m // i)return n, mif N % M == 0:ans = N // Mwhile not ans % 10:ans //= 10else:N, M = prime(N, M)if (tmp := to_and_five(M)):N %= 10for i in tmp:if i == 5:N *= 2else:N *= 5N %= 10ans = Nelse:ans = -1print(ans)