結果

問題 No.826 連絡網
ユーザー kohei2019kohei2019
提出日時 2022-04-20 21:56:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 94,188 KB
最終ジャッジ日時 2023-09-02 17:34:48
合計ジャッジ時間 7,249 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,772 KB
testcase_01 AC 69 ms
71,652 KB
testcase_02 AC 71 ms
71,652 KB
testcase_03 AC 79 ms
76,340 KB
testcase_04 AC 81 ms
76,656 KB
testcase_05 AC 77 ms
76,544 KB
testcase_06 AC 78 ms
76,400 KB
testcase_07 AC 80 ms
76,656 KB
testcase_08 AC 79 ms
76,308 KB
testcase_09 AC 77 ms
76,676 KB
testcase_10 AC 74 ms
76,380 KB
testcase_11 AC 79 ms
76,328 KB
testcase_12 AC 115 ms
88,792 KB
testcase_13 AC 99 ms
80,756 KB
testcase_14 AC 110 ms
85,768 KB
testcase_15 AC 88 ms
77,448 KB
testcase_16 AC 99 ms
82,184 KB
testcase_17 AC 99 ms
80,920 KB
testcase_18 AC 98 ms
79,428 KB
testcase_19 AC 137 ms
90,920 KB
testcase_20 AC 122 ms
90,248 KB
testcase_21 AC 85 ms
76,512 KB
testcase_22 AC 95 ms
80,932 KB
testcase_23 AC 98 ms
82,376 KB
testcase_24 AC 94 ms
78,496 KB
testcase_25 AC 131 ms
94,160 KB
testcase_26 AC 94 ms
79,084 KB
testcase_27 AC 115 ms
89,468 KB
testcase_28 AC 107 ms
86,400 KB
testcase_29 AC 94 ms
80,908 KB
testcase_30 AC 119 ms
94,188 KB
testcase_31 AC 89 ms
82,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primeset(N): #N以下の素数をsetで求める.エラトステネスの篩O(√Nlog(N))
    lsx = [1]*(N+1)
    for i in range(2,int(-(-N**0.5//1))+1):
        if lsx[i] == 1:
            for j in range(i,N//i+1):
                lsx[j*i] = 0
    setprime = set()
    for i in range(2,N+1):
        if lsx[i] == 1:
            setprime.add(i)
    return setprime
N,P = map(int,input().split())
if N <= 3:
    print(1)
    exit()
al = N//2
lsp = list(primeset(al))
lsp.sort()
ls = [0]*(N+1)
for p in lsp:
    st = 1
    while st*p <= N:
        ls[st*p] = 1
        st += 1
if ls[P] == 0:
    print(1)
else:
    print(sum(ls))
0