結果

問題 No.6 使いものにならないハッシュ
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-09 13:43:03
言語 Python2
(2.7.18)
結果
AC  
実行時間 204 ms / 5,000 ms
コード長 690 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 6,732 KB
実行使用メモリ 16,812 KB
最終ジャッジ日時 2023-10-14 22:49:06
合計ジャッジ時間 5,310 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,852 KB
testcase_01 AC 10 ms
5,860 KB
testcase_02 AC 204 ms
16,812 KB
testcase_03 AC 44 ms
7,616 KB
testcase_04 AC 65 ms
9,844 KB
testcase_05 AC 66 ms
8,768 KB
testcase_06 AC 126 ms
13,168 KB
testcase_07 AC 98 ms
13,072 KB
testcase_08 AC 119 ms
13,712 KB
testcase_09 AC 120 ms
16,280 KB
testcase_10 AC 11 ms
5,848 KB
testcase_11 AC 44 ms
7,500 KB
testcase_12 AC 140 ms
13,112 KB
testcase_13 AC 106 ms
15,508 KB
testcase_14 AC 114 ms
15,608 KB
testcase_15 AC 117 ms
12,468 KB
testcase_16 AC 123 ms
15,460 KB
testcase_17 AC 168 ms
16,700 KB
testcase_18 AC 197 ms
16,768 KB
testcase_19 AC 164 ms
16,040 KB
testcase_20 AC 142 ms
14,132 KB
testcase_21 AC 30 ms
6,856 KB
testcase_22 AC 156 ms
15,388 KB
testcase_23 AC 138 ms
13,244 KB
testcase_24 AC 145 ms
14,456 KB
testcase_25 AC 103 ms
12,904 KB
testcase_26 AC 173 ms
16,004 KB
testcase_27 AC 145 ms
15,488 KB
testcase_28 AC 91 ms
10,844 KB
testcase_29 AC 179 ms
16,020 KB
testcase_30 AC 161 ms
14,408 KB
testcase_31 AC 148 ms
14,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K=int(raw_input())
N=int(raw_input())
isPrime=[True for i in range(N+1)]
isPrime[0]=False
isPrime[1]=False
primes=[]
for i in range(N+1):
   if isPrime[i]:
      for j in range(i+i,N+1,i):
         isPrime[j]=False
      if i>=K and i <=N:
         primes.append(i)
hashs=[]
for p in primes:
   while p>=10:
      q = 0
      while p!=0:
         q+=p%10
         p/=10
      p=q
   hashs.append(p)

maxLen=0
ans = 2
for i in range(len(primes)):
   isUsed=[False for k in range(10)]
   curLen=0
   j = i
   while j<len(primes) and isUsed[hashs[j]]== False:
      isUsed[hashs[j]]=True
      curLen+=1
      j+=1
   if maxLen <= curLen:
      maxLen = curLen
      ans = primes[i]
print ans
0