結果

問題 No.36 素数が嫌い!
ユーザー matriematrie
提出日時 2020-12-22 07:30:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 600 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 12,104 KB
実行使用メモリ 588,928 KB
最終ジャッジ日時 2023-10-21 12:26:13
合計ジャッジ時間 8,998 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

def f(n):
	if n == 2: return True
	if n == 1 or n & 1 == 0: return False
	d = (n - 1) >> 1
	while d & 1 == 0: d >>= 1
	for k in range(100):
		a = random.randint(1, n - 1)
		t = d
		y = pow(a, t, n)
		while t != n - 1 and y != 1 and y != n - 1:
			y = (y * y) % n
			t <<= 1
		if y != n - 1 and t & 1 == 0:
			return False
	return True

def c(x):
	l=list(range(2,int(x**.5)+1))+[x]
	t=0
	while len(l)>0 and l[-1]==x:
		t=l[0]
		print(t)
		l=[i for i in l if i%t>0]
	return t
	
s="NO"
n=int(input())
fn=f(n);
if fn: print("NO")
else:
	a=c(n);
	b=c(n//a)
	print("YES" if a*b<n else "NO")
0