結果

問題 No.36 素数が嫌い!
ユーザー pekempeypekempey
提出日時 2015-09-25 14:28:31
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,824 ms / 5,000 ms
コード長 907 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 9,348 KB
最終ジャッジ日時 2023-09-09 07:22:09
合計ジャッジ時間 9,540 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 436 ms
9,192 KB
testcase_01 AC 49 ms
9,268 KB
testcase_02 AC 17 ms
9,276 KB
testcase_03 AC 17 ms
9,264 KB
testcase_04 AC 17 ms
9,188 KB
testcase_05 AC 21 ms
9,272 KB
testcase_06 AC 23 ms
9,248 KB
testcase_07 AC 23 ms
9,264 KB
testcase_08 AC 16 ms
9,340 KB
testcase_09 AC 17 ms
9,100 KB
testcase_10 AC 17 ms
9,288 KB
testcase_11 AC 606 ms
9,276 KB
testcase_12 AC 1,824 ms
9,152 KB
testcase_13 AC 1,819 ms
9,308 KB
testcase_14 AC 23 ms
9,344 KB
testcase_15 AC 17 ms
9,188 KB
testcase_16 AC 17 ms
9,152 KB
testcase_17 AC 17 ms
9,264 KB
testcase_18 AC 17 ms
9,336 KB
testcase_19 AC 90 ms
9,340 KB
testcase_20 AC 74 ms
9,344 KB
testcase_21 AC 253 ms
9,264 KB
testcase_22 AC 44 ms
9,264 KB
testcase_23 AC 28 ms
9,272 KB
testcase_24 AC 276 ms
9,192 KB
testcase_25 AC 327 ms
9,188 KB
testcase_26 AC 645 ms
9,336 KB
testcase_27 AC 49 ms
9,272 KB
testcase_28 AC 635 ms
9,348 KB
testcase_29 AC 30 ms
9,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math, itertools, random, collections, time

def suspect(a, e, k, n):
	a = pow(a, e, n)
	if a == 1: return True
	for _ in xrange(k):
		if a == n - 1: return True
		a = a * a % n
	return False

def isprime(n):
	if n == 1: return False
	e = n - 1
	k = 0
	while e % 2 == 0:
		e /= 2
		k += 1
	if n < 2 ** 31:
		bases = [2, 3, 5, 7]
	else:
		bases = [2, 325, 9375, 28178, 450775, 9780504, 1795265022]
	for i in bases:
		if n != i and not suspect(i, e, k, n): return False
	return True

def gcd(a, b):
	if b == 0: return a
	return gcd(b, a % b)

def rho(n):
	for c in xrange(1, n):
		if c == n - 2: continue
		x, y, d = 2, 2, 1
		f = lambda x: (x * x + c) % n
		while d == 1:
			x, y = f(x), f(f(y))
			d = gcd(abs(x - y), n)
		if d != n: return d
	return -1

n = input()
i = 2
c = 0
while i * i <= n:
	while n % i == 0:
		c += 1
		n /= i
	i += 1
if n != 1: c += 1
if c >= 3:
	print "YES"
else:
	print "NO"
0