結果

問題 No.826 連絡網
ユーザー titiatitia
提出日時 2019-05-03 21:48:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 423 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 48,276 KB
最終ジャッジ日時 2023-08-15 18:16:07
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,384 KB
testcase_01 AC 16 ms
8,244 KB
testcase_02 AC 16 ms
8,248 KB
testcase_03 AC 18 ms
8,632 KB
testcase_04 AC 19 ms
8,680 KB
testcase_05 AC 17 ms
8,360 KB
testcase_06 AC 17 ms
8,536 KB
testcase_07 AC 19 ms
8,512 KB
testcase_08 AC 17 ms
8,540 KB
testcase_09 AC 19 ms
8,596 KB
testcase_10 AC 17 ms
8,456 KB
testcase_11 AC 18 ms
8,428 KB
testcase_12 AC 310 ms
37,264 KB
testcase_13 AC 122 ms
19,840 KB
testcase_14 AC 226 ms
29,856 KB
testcase_15 AC 39 ms
11,024 KB
testcase_16 AC 150 ms
22,876 KB
testcase_17 AC 120 ms
19,928 KB
testcase_18 AC 97 ms
17,408 KB
testcase_19 AC 370 ms
41,680 KB
testcase_20 AC 352 ms
41,112 KB
testcase_21 AC 20 ms
8,680 KB
testcase_22 AC 122 ms
20,032 KB
testcase_23 AC 155 ms
23,448 KB
testcase_24 AC 71 ms
14,904 KB
testcase_25 AC 421 ms
48,008 KB
testcase_26 AC 88 ms
16,176 KB
testcase_27 AC 320 ms
38,256 KB
testcase_28 AC 231 ms
31,388 KB
testcase_29 AC 123 ms
19,852 KB
testcase_30 AC 423 ms
48,276 KB
testcase_31 AC 146 ms
22,080 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