結果

問題 No.826 連絡網
ユーザー ttrttr
提出日時 2020-02-26 16:55:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 993 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 26,360 KB
最終ジャッジ日時 2024-04-21 16:29:46
合計ジャッジ時間 10,966 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,752 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 33 ms
10,624 KB
testcase_03 AC 37 ms
10,880 KB
testcase_04 AC 39 ms
10,880 KB
testcase_05 AC 36 ms
10,752 KB
testcase_06 AC 34 ms
10,752 KB
testcase_07 AC 37 ms
10,880 KB
testcase_08 AC 34 ms
10,624 KB
testcase_09 AC 37 ms
10,880 KB
testcase_10 AC 33 ms
10,624 KB
testcase_11 AC 36 ms
10,880 KB
testcase_12 AC 701 ms
21,980 KB
testcase_13 AC 259 ms
15,232 KB
testcase_14 AC 508 ms
19,168 KB
testcase_15 AC 77 ms
11,648 KB
testcase_16 AC 335 ms
16,328 KB
testcase_17 AC 250 ms
15,232 KB
testcase_18 AC 212 ms
14,208 KB
testcase_19 AC 832 ms
23,660 KB
testcase_20 AC 792 ms
23,552 KB
testcase_21 AC 41 ms
10,880 KB
testcase_22 AC 268 ms
15,104 KB
testcase_23 AC 343 ms
16,412 KB
testcase_24 AC 152 ms
13,312 KB
testcase_25 AC 986 ms
26,156 KB
testcase_26 AC 181 ms
13,824 KB
testcase_27 AC 704 ms
22,280 KB
testcase_28 AC 533 ms
19,716 KB
testcase_29 AC 268 ms
15,080 KB
testcase_30 AC 993 ms
26,360 KB
testcase_31 AC 295 ms
16,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

memo = [-1]*(N+1)
for i in range(2, N+1):
    if memo[i] > -1:
        continue
    memo[i] = 1
    j = 2*i
    while j <= N:
        memo[j] = 0
        j += i

if P > 1:
    L = [0]*(N+1)
    n = 2
    num = P
    while n <= P**0.5:
        if P%n == 0:
            num = n
            break
        n += 1
    if num*2 <= N:
        ans = N//2-1
        for i in range(N//2+1, N+1):
            if memo[i] == 0:
                ans += 1
    else:
        ans = 1

print(ans)
0