結果

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

テストケース

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

ソースコード

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(300000):
        if isPrime(i)==1:
            if b%i==0:
                flag = 1
    if flag == 0:
        print 14
    else:
        print 8
     
0