結果

問題 No.12 限定された素数
ユーザー konchanksukonchanksu
提出日時 2020-04-30 02:01:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 49,344 KB
最終ジャッジ日時 2023-08-20 17:47:21
合計ジャッジ時間 44,787 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,579 ms
47,716 KB
testcase_01 AC 1,640 ms
47,428 KB
testcase_02 AC 1,591 ms
47,368 KB
testcase_03 WA -
testcase_04 AC 1,565 ms
47,476 KB
testcase_05 AC 1,633 ms
47,524 KB
testcase_06 AC 1,624 ms
47,576 KB
testcase_07 AC 1,584 ms
47,352 KB
testcase_08 AC 1,649 ms
47,536 KB
testcase_09 AC 1,572 ms
49,344 KB
testcase_10 AC 1,630 ms
47,472 KB
testcase_11 AC 1,576 ms
47,516 KB
testcase_12 AC 1,607 ms
47,568 KB
testcase_13 AC 1,611 ms
47,372 KB
testcase_14 AC 1,619 ms
47,772 KB
testcase_15 AC 1,606 ms
47,432 KB
testcase_16 AC 1,583 ms
47,572 KB
testcase_17 AC 1,560 ms
47,664 KB
testcase_18 AC 1,598 ms
47,412 KB
testcase_19 AC 1,569 ms
48,964 KB
testcase_20 AC 1,568 ms
47,344 KB
testcase_21 AC 1,623 ms
47,456 KB
testcase_22 AC 1,546 ms
47,480 KB
testcase_23 AC 1,560 ms
47,580 KB
testcase_24 AC 1,541 ms
47,368 KB
testcase_25 AC 1,621 ms
47,520 KB
権限があれば一括ダウンロードができます

ソースコード

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)
nokori = copy(A)
left = 1

for i in prime:
    tmp = set(str(i))
    if A | tmp != A:
        if not nokori:     
            ans = max(ans, abs(i - left - 1))
        left = i + 1
        nokori = copy(A)
        continue

    nokori -= tmp

print(max(ans, 4999999 - left))
0