結果
問題 | No.677 10^Nの約数 |
ユーザー | yuppe19 😺 |
提出日時 | 2018-07-25 21:36:27 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 2,106 bytes |
コンパイル時間 | 229 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 8,796 KB |
最終ジャッジ日時 | 2024-06-27 03:30:57 |
合計ジャッジ時間 | 1,889 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
8,668 KB |
testcase_01 | AC | 25 ms
8,668 KB |
testcase_02 | AC | 25 ms
8,664 KB |
testcase_03 | AC | 25 ms
8,540 KB |
testcase_04 | AC | 25 ms
8,536 KB |
testcase_05 | AC | 24 ms
8,664 KB |
testcase_06 | AC | 25 ms
8,664 KB |
testcase_07 | AC | 25 ms
8,540 KB |
testcase_08 | AC | 24 ms
8,668 KB |
testcase_09 | AC | 25 ms
8,796 KB |
testcase_10 | AC | 24 ms
8,664 KB |
testcase_11 | AC | 25 ms
8,668 KB |
testcase_12 | AC | 25 ms
8,668 KB |
testcase_13 | AC | 25 ms
8,664 KB |
testcase_14 | AC | 25 ms
8,668 KB |
testcase_15 | AC | 25 ms
8,668 KB |
testcase_16 | AC | 26 ms
8,664 KB |
testcase_17 | AC | 26 ms
8,540 KB |
testcase_18 | AC | 26 ms
8,668 KB |
ソースコード
#!/usr/bin/python2 # -*- coding: utf-8 -*- # † from collections import defaultdict, deque from fractions import gcd from itertools import product from operator import mul from random import randrange def is_probable_prime(n, k=20): if n == 1: return False for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]: if n == p: return True if n % p == 0: return False s, d = 0, n-1 while d & 1 == 0: s, d = s+1, d>>1 for _ in xrange(k): a = randrange(2, n-1) x = pow(a, d, n) if x == 1 or x == n-1: continue for _ in xrange(s-1): x = (x * x) % n if x == n-1: break # could be strong liar, try another a else: return False # composite if we reached end of this loop return True # probably prime if reached end of outer loop def brent(n): if not n & 1: return 2 x = randrange(0, n) c = randrange(1, n) m = randrange(1, n) y, r, q = x, 1, 1 g, ys = 0, 0 while g <= 1: x = y for _ in xrange(r): y = (y*y + c) % n k = 0 while k < r and g <= 1: ys = y for _ in xrange(min(m, r-k)): y = (y*y + c) % n q = (q*abs(x-y)) % n g, k = gcd(q, n), k+m r <<= 1 if g == n: while g <= 1: ys = (ys*ys + c) % n g = gcd(abs(x-ys), n) return g def factorize(n): que = deque() res = defaultdict(int) if n == 1: return res que.append(n) while len(que): l = que.pop() if is_probable_prime(l): res[l] += 1 continue d = brent(l) que.append(d) if d != l: que.append(l//d) return res def fast_divisors(n): fac = factorize(n) res = sorted(set(reduce(mul, [x**y for x, y in zip(fac.keys(), pro)] or [1]) for pro in product(*(xrange(v+1) for v in fac.values())))) return res n = int(raw_input()) divs = fast_divisors(10**n) res = '\n'.join(map(str, divs)) print res