結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2015-08-31 02:04:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 685 bytes |
コンパイル時間 | 126 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-07-18 15:52:15 |
合計ジャッジ時間 | 2,380 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 s = set() while True: while n < m: n *= 10 x, n = divmod(n, m) if n in s: print(-1) return if n == 0: while x % 10 == 0: x //= 10 print(x % 10) return s.add(n) if __name__ == '__main__': solve()