結果

問題 No.36 素数が嫌い!
ユーザー matrie
提出日時 2020-12-22 00:41:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 294 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-09-21 13:33:50
合計ジャッジ時間 2,030 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
n=int(input())
s=1
if n>2:
	k,m=0,n-1
	while m&1==0: k+=1; m>>=1
	
	def p(n):
		a=random.randint(2,n-1)
		b=pow(a,m,n)
		if b==1: return False
		for i in range(k):
			if b==n-1: return False
			b=pow(b,2,n)
		return True
		
	for i in [0]*100:
		if p(n): s=0
print(["YES","NO"][s])
0