結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2022-02-13 07:40:54 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 628 bytes |
コンパイル時間 | 80 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 17,436 KB |
最終ジャッジ日時 | 2024-06-29 05:25:37 |
合計ジャッジ時間 | 12,776 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 TLE * 1 -- * 14 |
ソースコード
from math import gcd, sqrt def Fraction(A, B): G = gcd(A, B) return A // G, B // G def PrimeFactorization(N): ret = [] for i in range(2,int(sqrt(N))+1): while N % i == 0: ret.append(i) N //= i if N > 1: ret.append(N) return ret N = int(input()) M = int(input()) N,M = Fraction(N, M) P = PrimeFactorization(M) T = 0 F = 0 for i in P: if i != 2 and i != 5: print(-1) exit() if i == 2: T += 1 else: F += 1 while T > F: N *= 5 T -= 1 while T < F: N *= 2 F -= 1 while N % 10 == 0: N //= 10 print(N % 10)