結果

問題 No.826 連絡網
ユーザー stngstng
提出日時 2022-07-09 17:51:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 93,580 KB
最終ジャッジ日時 2023-08-30 01:47:21
合計ジャッジ時間 4,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,544 KB
testcase_01 AC 72 ms
71,404 KB
testcase_02 AC 71 ms
71,228 KB
testcase_03 AC 76 ms
76,356 KB
testcase_04 AC 77 ms
76,680 KB
testcase_05 AC 75 ms
76,448 KB
testcase_06 AC 74 ms
76,352 KB
testcase_07 AC 76 ms
76,440 KB
testcase_08 AC 75 ms
76,356 KB
testcase_09 AC 78 ms
76,524 KB
testcase_10 AC 76 ms
76,280 KB
testcase_11 AC 77 ms
76,448 KB
testcase_12 AC 108 ms
88,316 KB
testcase_13 AC 90 ms
80,216 KB
testcase_14 AC 99 ms
84,960 KB
testcase_15 AC 81 ms
77,128 KB
testcase_16 AC 93 ms
81,644 KB
testcase_17 AC 89 ms
80,432 KB
testcase_18 AC 87 ms
79,104 KB
testcase_19 AC 110 ms
90,420 KB
testcase_20 AC 109 ms
90,268 KB
testcase_21 AC 76 ms
76,584 KB
testcase_22 AC 89 ms
80,212 KB
testcase_23 AC 93 ms
81,848 KB
testcase_24 AC 85 ms
77,956 KB
testcase_25 AC 120 ms
93,440 KB
testcase_26 AC 85 ms
78,456 KB
testcase_27 AC 110 ms
89,192 KB
testcase_28 AC 101 ms
85,584 KB
testcase_29 AC 91 ms
80,136 KB
testcase_30 AC 116 ms
93,580 KB
testcase_31 AC 93 ms
81,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def sieve_of_eratosthenes(n):
    prime = [True for i in range(n+1)]
    prime[0] = False
    prime[1] = False

    sqrt_n = math.ceil(math.sqrt(n))
    for i in range(2, sqrt_n):
        if prime[i]:
            for j in range(2*i, n+1, i):
                prime[j] = False

    return prime

n,p = map(int,input().split())
prm = sieve_of_eratosthenes(n)
pm = []
for i in range(n+1):
    if prm[i] == True:
        pm.append(i)

mr = set()

for i in range(len(pm)):
    if pm[i]*2 > n:
        #idx = i
        mr.add(pm[i])

#print(idx,pm[idx],len(pm)-idx)
if p in mr:
    print(1)
else:
    print(n-len(mr)-1)
0