結果

問題 No.826 連絡網
ユーザー roarisroaris
提出日時 2019-09-20 00:01:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 88,384 KB
最終ジャッジ日時 2023-09-28 23:52:16
合計ジャッジ時間 5,261 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,548 KB
testcase_01 AC 76 ms
71,464 KB
testcase_02 AC 77 ms
71,708 KB
testcase_03 AC 83 ms
75,740 KB
testcase_04 AC 80 ms
75,832 KB
testcase_05 AC 80 ms
75,656 KB
testcase_06 AC 80 ms
75,780 KB
testcase_07 AC 81 ms
75,648 KB
testcase_08 AC 82 ms
75,692 KB
testcase_09 AC 82 ms
75,756 KB
testcase_10 AC 81 ms
75,868 KB
testcase_11 AC 82 ms
75,900 KB
testcase_12 WA -
testcase_13 AC 91 ms
78,868 KB
testcase_14 AC 104 ms
82,044 KB
testcase_15 AC 81 ms
76,476 KB
testcase_16 AC 94 ms
79,740 KB
testcase_17 AC 90 ms
78,760 KB
testcase_18 AC 87 ms
78,192 KB
testcase_19 AC 113 ms
86,188 KB
testcase_20 AC 111 ms
86,148 KB
testcase_21 AC 81 ms
75,928 KB
testcase_22 AC 93 ms
78,960 KB
testcase_23 AC 95 ms
80,004 KB
testcase_24 AC 87 ms
77,080 KB
testcase_25 AC 120 ms
88,024 KB
testcase_26 AC 86 ms
77,512 KB
testcase_27 AC 109 ms
85,136 KB
testcase_28 AC 101 ms
83,132 KB
testcase_29 AC 90 ms
78,780 KB
testcase_30 AC 120 ms
88,384 KB
testcase_31 AC 93 ms
79,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

def era(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(2*i, n+1, i):
            is_prime[j] = False

    return [i for i in range(n) if is_prime[i]]

N, P = map(int, input().split())
primes = era(N)

if P == 1 or (P >= N//2+1 and P in primes):
    print(1)
else:
    print(N - 1 - (len(primes)-bisect_left(primes, N//2+1)))
0