結果

問題 No.12 限定された素数
ユーザー konchanksukonchanksu
提出日時 2020-04-30 01:40:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 49,612 KB
最終ジャッジ日時 2023-08-20 15:00:34
合計ジャッジ時間 46,065 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,603 ms
47,496 KB
testcase_01 AC 1,687 ms
47,664 KB
testcase_02 AC 1,602 ms
47,576 KB
testcase_03 AC 1,570 ms
47,624 KB
testcase_04 AC 1,620 ms
47,672 KB
testcase_05 AC 1,670 ms
47,584 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1,657 ms
47,664 KB
testcase_09 AC 1,603 ms
49,024 KB
testcase_10 AC 1,669 ms
47,536 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1,620 ms
49,136 KB
testcase_18 AC 1,600 ms
47,580 KB
testcase_19 AC 1,608 ms
49,008 KB
testcase_20 AC 1,613 ms
48,928 KB
testcase_21 AC 1,660 ms
47,612 KB
testcase_22 AC 1,616 ms
47,444 KB
testcase_23 AC 1,607 ms
47,456 KB
testcase_24 AC 1,607 ms
47,608 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import copy

def prime_num(end):
    prime_list = [True for i in range(end + 1)]
    prime_list[0], prime_list[1] = False, False
    
    for i in range(2, int(end ** 0.5) + 1):
        if not prime_list[i]:
            continue
        for j in range(i * 2, end + 1, i):
            prime_list[j] = False
            
    return (i for i in range(2, end + 1) if prime_list[i])
            
N = int(input())
A = set(input().split())
ans = -1

prime = prime_num(5 * 10 ** 6)
lists = copy(A)
left = 1
right = 1
nokori = copy(A)

for i in prime:
    right = i - 1
    tmp = set(str(i))
    if A | tmp != A:
        if nokori:
            left = i + 1
            nokori = copy(A)
            continue
        else:
            ans = max(ans, abs(right - left))
            nokori = copy(A)
            continue
    nokori = nokori - tmp
    
print(ans if len(A) != 10 else 4999999)
0