結果

問題 No.826 連絡網
ユーザー titiatitia
提出日時 2019-05-03 21:47:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 72,704 KB
最終ジャッジ日時 2024-05-03 05:03:02
合計ジャッジ時間 3,077 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,480 KB
testcase_01 AC 42 ms
52,608 KB
testcase_02 AC 41 ms
52,480 KB
testcase_03 AC 53 ms
59,008 KB
testcase_04 AC 47 ms
59,008 KB
testcase_05 AC 45 ms
59,520 KB
testcase_06 AC 50 ms
58,752 KB
testcase_07 AC 45 ms
59,008 KB
testcase_08 AC 44 ms
59,136 KB
testcase_09 AC 44 ms
59,384 KB
testcase_10 AC 45 ms
58,496 KB
testcase_11 AC 44 ms
59,008 KB
testcase_12 AC 68 ms
69,376 KB
testcase_13 AC 54 ms
63,744 KB
testcase_14 AC 62 ms
66,688 KB
testcase_15 AC 48 ms
59,776 KB
testcase_16 AC 57 ms
64,640 KB
testcase_17 AC 53 ms
63,872 KB
testcase_18 AC 52 ms
62,336 KB
testcase_19 AC 75 ms
70,528 KB
testcase_20 AC 69 ms
70,784 KB
testcase_21 AC 46 ms
59,264 KB
testcase_22 AC 54 ms
63,488 KB
testcase_23 AC 56 ms
64,512 KB
testcase_24 AC 49 ms
61,312 KB
testcase_25 AC 78 ms
72,704 KB
testcase_26 AC 51 ms
61,952 KB
testcase_27 AC 65 ms
69,504 KB
testcase_28 AC 60 ms
67,072 KB
testcase_29 AC 53 ms
63,104 KB
testcase_30 AC 74 ms
72,704 KB
testcase_31 AC 56 ms
64,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

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

if P==1:
    print(1)
    sys.exit()

import math 
L=math.ceil(math.sqrt(P))

if P>N//2:
    for i in range(2,L+1):
        if P%i==0:
            break

    else:
        print(1)
        sys.exit()



L=math.floor(math.sqrt(N))#平方根を求める

Primelist=[i for i in range(N+1)]
Primelist[1]=0#1は素数でないので0にする.
 
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,N+1,i):
        Primelist[j]=0

Primes=[Primelist[j] for j in range(N+1) if Primelist[j]!=0]

import bisect
ANS=bisect.bisect_right(Primes,N//2)
print(N-(len(Primes)-ANS+1))
0