結果

問題 No.308 素数は通れません
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-12-01 01:35:01
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 662 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 12,364 KB
最終ジャッジ日時 2023-10-12 06:49:29
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
12,364 KB
testcase_01 AC 12 ms
6,180 KB
testcase_02 AC 12 ms
6,128 KB
testcase_03 AC 11 ms
6,128 KB
testcase_04 AC 12 ms
6,084 KB
testcase_05 AC 12 ms
6,016 KB
testcase_06 AC 12 ms
6,088 KB
testcase_07 AC 12 ms
6,200 KB
testcase_08 AC 12 ms
6,016 KB
testcase_09 AC 12 ms
6,200 KB
testcase_10 AC 11 ms
6,128 KB
testcase_11 AC 11 ms
6,116 KB
testcase_12 AC 11 ms
6,192 KB
testcase_13 AC 12 ms
6,112 KB
testcase_14 AC 12 ms
6,036 KB
testcase_15 AC 12 ms
6,244 KB
testcase_16 AC 11 ms
6,128 KB
testcase_17 AC 12 ms
6,124 KB
testcase_18 AC 11 ms
6,124 KB
testcase_19 AC 11 ms
6,024 KB
testcase_20 AC 11 ms
6,196 KB
testcase_21 AC 12 ms
6,024 KB
testcase_22 AC 11 ms
6,140 KB
testcase_23 AC 12 ms
6,180 KB
testcase_24 AC 12 ms
6,140 KB
testcase_25 AC 12 ms
6,144 KB
testcase_26 AC 12 ms
6,092 KB
testcase_27 AC 11 ms
6,036 KB
testcase_28 AC 12 ms
6,088 KB
testcase_29 AC 12 ms
6,096 KB
testcase_30 AC 12 ms
6,088 KB
testcase_31 AC 12 ms
6,096 KB
testcase_32 AC 12 ms
6,240 KB
testcase_33 AC 11 ms
6,144 KB
testcase_34 AC 11 ms
6,192 KB
testcase_35 AC 11 ms
6,248 KB
testcase_36 TLE -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
testcase_94 -- -
testcase_95 -- -
testcase_96 -- -
testcase_97 -- -
testcase_98 -- -
testcase_99 -- -
testcase_100 -- -
testcase_101 -- -
testcase_102 -- -
testcase_103 -- -
testcase_104 -- -
testcase_105 -- -
testcase_106 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

x = input()

def isPrime(n):
  if n < 2:
    return 0
  elif n == 2:
    return 1
  for i in range(2, int(math.sqrt(n))+1):
    if not n % i:
      return 0
  return 1

d=[-1,-1,-1,-1,3,-1,5,-1,7,7,7,-1,11,-1,13,7,7,-1,8,-1,19,19,7,-1,23,23,8,8,8,-1,8,-1,8,8,8,8,8,-1,8,8,8,-1,8,-1,8,8,8,-1,8,14,8,8,8,-1,8,8,8,8,8,-1,8,-1,8,8,8,8,8,-1,8,8,8,-1,8,-1,8,8,8,8,8,-1,8,14,8,-1,8,8,8,8,8,-1,8,8,8,8,8,8,8,-1,8,8]

if x < 100:
    print d[x]
else:
    a = x-1
    b = x-8
    flag = 0
    for i in xrange(1000000):
        if isPrime(i)==1:
            if b%i==0:
                flag = 1
    if flag == 0:
        print 14
    else:
        print 8
     
0