結果
問題 | No.1339 循環小数 |
ユーザー | GER_chen |
提出日時 | 2021-01-22 15:59:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,071 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-06-08 02:23:14 |
合計ジャッジ時間 | 3,009 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
ソースコード
#yuki-1339 T = int(input()) candidates = [2*i+1 for i in range(1, 15811)] primelist = [2] p = 3 while p**2 <= 31623: primelist.append(p) candidates = [c for c in candidates if c%p] p = candidates[0] primelist += candidates l = len(primelist) def euler(n): """ nが奇数の時 """ i = 1 ans = n while i < l and primelist[i]**2 <= n: p = primelist[i] if not n%p: ans -= ans//p while not n%p: n //= p i += 1 if n > 1: ans -= ans//n return ans def divlist(n): from collections import defaultdict as ddt d = ddt(int) i = 0 while primelist[i]**2 <= n: p = primelist[i] while not n%p: d[p] += 1 n //= p i += 1 if n > 1: d[n] += 1 ans = {1} for k in d.keys(): plus = set() for x in ans: for ex in range(d[k]): plus.add(x*k**(ex+1)) ans |= plus return sorted(ans) def ediv(N): """ nが奇数の時 """ from collections import defaultdict as ddt d = ddt(int) i = 1 ans = n while i < l and primelist[i]**2 <= n: p = primelist[i] if not n%p: n //= p j = 0 m = p-1 while primelist[j]**2 <= m: p = primelist[j] while not m%p: d[p] += 1 m //= p j += 1 if n > 1: d[n] += 1 while not n%p: n //= p d[p] += 1 i += 1 ans = {1} for k in d.keys(): plus = set() for x in ans: for ex in range(d[k]): plus.add(x*k**(ex+1)) ans |= plus return sorted(ans) for _ in range(T): N = int(input()) #10**9以下 while not N%2: N //= 2 while not N%5: N //= 5 if N == 1: print(1) for d in ediv(N): if pow(10, d, N) == 1: print(d) break