結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2015-08-31 02:24:41 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 966 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-11-15 21:13:56 |
合計ジャッジ時間 | 2,254 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 31 |
ソースコード
from fractions import gcd def sieve(n): s = [True] * n for x in range(2, int(n ** 0.5) + 1): if s[x]: for i in range(x + x, n, x): s[i] = False return [i for i in range(n) if s[i] and i > 1] def solve(): N = int(input()) M = int(input()) g = gcd(N, M) n = N // g m = M // g if m == 1: while n % 10 == 0: n //= 10 print(n % 10) return o = m c2 = c5 = 0 while True: p, y = divmod(o, 5) if y: break o = p c5 += 1 while True: p, y = divmod(o, 2) if y: break o = p c2 += 1 if o != 1: print(-1) return if c2 == c5: d = 1 elif c2 > c5: d = 5 else: c5 -= c2 d = 2 ** c5 % 10 n *= d while n % 10 == 0: n //= 10 print(n % 10) if __name__ == '__main__': solve()