結果

問題 No.12 限定された素数
ユーザー chocoruskchocorusk
提出日時 2020-09-07 23:02:05
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 3,481 ms / 5,000 ms
コード長 700 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 95,984 KB
最終ジャッジ日時 2023-08-19 17:18:29
合計ジャッジ時間 89,374 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,230 ms
95,856 KB
testcase_01 AC 3,191 ms
94,676 KB
testcase_02 AC 3,249 ms
94,684 KB
testcase_03 AC 3,481 ms
94,760 KB
testcase_04 AC 3,147 ms
94,644 KB
testcase_05 AC 3,222 ms
94,540 KB
testcase_06 AC 3,254 ms
94,712 KB
testcase_07 AC 3,249 ms
94,744 KB
testcase_08 AC 3,243 ms
94,664 KB
testcase_09 AC 3,257 ms
94,692 KB
testcase_10 AC 3,320 ms
94,756 KB
testcase_11 AC 3,308 ms
94,568 KB
testcase_12 AC 3,279 ms
95,920 KB
testcase_13 AC 3,242 ms
94,544 KB
testcase_14 AC 3,253 ms
94,564 KB
testcase_15 AC 3,302 ms
94,820 KB
testcase_16 AC 3,320 ms
94,656 KB
testcase_17 AC 3,327 ms
95,984 KB
testcase_18 AC 3,122 ms
94,660 KB
testcase_19 AC 3,268 ms
94,684 KB
testcase_20 AC 3,212 ms
94,648 KB
testcase_21 AC 3,351 ms
94,672 KB
testcase_22 AC 3,220 ms
95,968 KB
testcase_23 AC 3,162 ms
94,848 KB
testcase_24 AC 3,198 ms
94,852 KB
testcase_25 AC 3,253 ms
94,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_sieve(n):
    isprime=[True]*(n+1)
    isprime[0]=False
    isprime[1]=False
    for i in range(2, n+1):
        if isprime[i]:
            for j in range(2*i, n+1, i):
                isprime[j]=False
    return isprime
n=int(input())
a=list(map(int, input().split()))
b=0
for x in a:
    b^=(1<<x)
isprime=prime_sieve(5000000)
def digit(x):
    if not isprime[x]:
        return 0
    b=0
    while x>0:
        b|=(1<<(x%10))
        x//=10
    return b
d=[digit(i) for i in range(5000001)]
pr=0
s=0
ans=-1
for i, x in enumerate(d):
    if (x|b)==b:
        s|=x
        continue
    if s==b:
        ans=max(ans, i-pr-2)
    pr=i
    s=0
if s==b:
    ans=max(ans, 4999999-pr)
print(ans)
0