結果

問題 No.826 連絡網
ユーザー 👑 rin204rin204
提出日時 2022-03-25 04:36:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 70,272 KB
最終ジャッジ日時 2024-04-21 13:17:54
合計ジャッジ時間 4,851 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
65,792 KB
testcase_01 AC 90 ms
66,048 KB
testcase_02 AC 88 ms
66,176 KB
testcase_03 AC 85 ms
66,560 KB
testcase_04 AC 84 ms
66,304 KB
testcase_05 AC 87 ms
66,304 KB
testcase_06 AC 91 ms
66,688 KB
testcase_07 AC 87 ms
66,304 KB
testcase_08 AC 85 ms
66,688 KB
testcase_09 AC 87 ms
66,048 KB
testcase_10 AC 87 ms
66,176 KB
testcase_11 AC 85 ms
66,432 KB
testcase_12 AC 93 ms
69,120 KB
testcase_13 AC 88 ms
67,584 KB
testcase_14 AC 86 ms
68,480 KB
testcase_15 AC 84 ms
66,816 KB
testcase_16 AC 86 ms
67,840 KB
testcase_17 AC 86 ms
67,328 KB
testcase_18 AC 91 ms
67,328 KB
testcase_19 AC 97 ms
69,376 KB
testcase_20 AC 96 ms
69,760 KB
testcase_21 AC 90 ms
66,432 KB
testcase_22 AC 99 ms
67,328 KB
testcase_23 AC 86 ms
67,968 KB
testcase_24 AC 85 ms
67,072 KB
testcase_25 AC 88 ms
70,272 KB
testcase_26 AC 83 ms
67,072 KB
testcase_27 AC 88 ms
69,504 KB
testcase_28 AC 87 ms
68,736 KB
testcase_29 AC 84 ms
67,328 KB
testcase_30 AC 91 ms
70,144 KB
testcase_31 AC 88 ms
67,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 1000100
isprime = [True] * N
isprime[0] = isprime[1] = False
for i in range(2, int(N ** 0.5 + 1)):
    if not isprime[i]:
        continue
    for j in range(i * i, N, i):
        isprime[j] = False

n, p = map(int, input().split())
for i in range(2, int(p ** 0.5 + 1)):
    if p % i == 0:
        p = i
        break
    
if 2 * p <= n:
    ans = n - sum(isprime[n // 2 + 1:n + 1]) - 1
    print(ans)
else:
    print(1)
0