結果
| 問題 | No.12 限定された素数 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-11-02 04:23:57 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 946 bytes |
| 記録 | |
| コンパイル時間 | 312 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 307,676 KB |
| 最終ジャッジ日時 | 2024-10-11 01:40:42 |
| 合計ジャッジ時間 | 12,921 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 25 |
ソースコード
from collections import Counter
N=int(input())
A=Counter(input().split())
x=5000000
import math
L=math.floor(math.sqrt(x)) # 平方根を求める
Primelist=[i for i in range(x+1)]
Primelist[1]=0 # 1は素数でないので0にする.
for i in Primelist:
if i>L:
break
if i==0:
continue
for j in range(2*i,x+1,i):
Primelist[j]=0
Primes=[0]+[Primelist[j] for j in range(x+1) if Primelist[j]!=0]
P2=[]
for p in Primes:
P2.append(Counter(str(p)))
S=Counter()
ANS=-1
end=1
for now in range(1,len(Primes)):
while set(S)<=set(A):
if set(S)==set(A):
if end==348514:
ANS=max(ANS,5000001-Primes[now-1]-2)
else:
ANS=max(ANS,Primes[end]-Primes[now-1]-2)
if end==348514:
break
S+=P2[end]
end+=1
#print(Primes[now],Primes[end],ANS,A,S)
S-=P2[now]
print(ANS)
titia