結果

問題 No.308 素数は通れません
ユーザー kzyKT
提出日時 2015-12-01 02:17:43
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 412 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 14,240 KB
最終ジャッジ日時 2024-09-14 06:17:48
合計ジャッジ時間 4,587 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55 WA * 1 TLE * 1 -- * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
def solve(x):
  x=x-1
  while x%2==0:
    x>>=1
  for l in range(0,30):
    r=random.randint(1,x-1)
    t=x
    y=pow(r,t,x)
    while t!=x-1 and y!=1 and y!=x-1:
      y=(y*y)%x
      t<<=1
    if y!=x-1 and t&1==0:
      return False
  return True
a=[0,0,0,0,3,0,5,0,7,7,7,0,11,0,13,7,7,0,8,0,19,19,7,0,23,23]
x=input()
if x<26:print a[x]
else:print 14 if (x-1)%8==0 and x%2 and solve(x-8) else 8
0