結果

問題 No.826 連絡網
ユーザー titiatitia
提出日時 2019-05-03 21:47:48
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 86,320 KB
実行使用メモリ 88,452 KB
最終ジャッジ日時 2023-08-15 18:12:15
合計ジャッジ時間 4,861 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,140 KB
testcase_01 AC 63 ms
71,156 KB
testcase_02 AC 64 ms
71,080 KB
testcase_03 AC 73 ms
75,728 KB
testcase_04 AC 71 ms
75,780 KB
testcase_05 AC 70 ms
75,832 KB
testcase_06 AC 68 ms
75,992 KB
testcase_07 AC 67 ms
75,792 KB
testcase_08 AC 69 ms
75,796 KB
testcase_09 AC 69 ms
76,004 KB
testcase_10 AC 67 ms
75,764 KB
testcase_11 AC 67 ms
75,952 KB
testcase_12 AC 84 ms
84,880 KB
testcase_13 AC 75 ms
78,680 KB
testcase_14 AC 84 ms
81,896 KB
testcase_15 AC 68 ms
76,500 KB
testcase_16 AC 74 ms
79,904 KB
testcase_17 AC 72 ms
78,904 KB
testcase_18 AC 72 ms
78,148 KB
testcase_19 AC 85 ms
86,236 KB
testcase_20 AC 88 ms
86,152 KB
testcase_21 AC 70 ms
75,776 KB
testcase_22 AC 74 ms
79,128 KB
testcase_23 AC 76 ms
80,172 KB
testcase_24 AC 74 ms
76,888 KB
testcase_25 AC 93 ms
88,452 KB
testcase_26 AC 74 ms
77,716 KB
testcase_27 AC 83 ms
85,216 KB
testcase_28 AC 81 ms
82,740 KB
testcase_29 AC 75 ms
78,504 KB
testcase_30 AC 90 ms
88,132 KB
testcase_31 AC 78 ms
79,488 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