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