結果

問題 No.843 Triple Primes
ユーザー titiatitia
提出日時 2019-06-28 21:40:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 75,520 KB
最終ジャッジ日時 2023-10-19 17:34:04
合計ジャッジ時間 5,737 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,716 KB
testcase_01 AC 152 ms
75,520 KB
testcase_02 AC 43 ms
60,260 KB
testcase_03 AC 43 ms
60,260 KB
testcase_04 AC 43 ms
60,260 KB
testcase_05 AC 43 ms
60,260 KB
testcase_06 AC 44 ms
60,260 KB
testcase_07 AC 112 ms
72,788 KB
testcase_08 AC 122 ms
73,984 KB
testcase_09 AC 151 ms
75,492 KB
testcase_10 AC 120 ms
72,936 KB
testcase_11 AC 131 ms
74,180 KB
testcase_12 AC 144 ms
75,388 KB
testcase_13 AC 137 ms
74,312 KB
testcase_14 AC 137 ms
74,316 KB
testcase_15 AC 111 ms
72,852 KB
testcase_16 AC 111 ms
72,908 KB
testcase_17 AC 36 ms
53,716 KB
testcase_18 AC 36 ms
53,716 KB
testcase_19 AC 36 ms
53,716 KB
testcase_20 AC 55 ms
64,212 KB
testcase_21 AC 49 ms
62,880 KB
testcase_22 AC 76 ms
69,592 KB
testcase_23 AC 79 ms
70,292 KB
testcase_24 AC 55 ms
64,280 KB
testcase_25 AC 58 ms
63,604 KB
testcase_26 AC 150 ms
75,480 KB
testcase_27 AC 46 ms
62,528 KB
testcase_28 AC 141 ms
74,360 KB
testcase_29 AC 57 ms
66,632 KB
testcase_30 AC 146 ms
75,408 KB
testcase_31 AC 47 ms
62,656 KB
testcase_32 AC 45 ms
62,500 KB
testcase_33 AC 58 ms
66,780 KB
testcase_34 AC 73 ms
69,376 KB
testcase_35 AC 150 ms
75,492 KB
testcase_36 AC 53 ms
63,344 KB
testcase_37 AC 103 ms
72,640 KB
testcase_38 AC 87 ms
70,644 KB
testcase_39 AC 144 ms
75,024 KB
testcase_40 AC 37 ms
53,716 KB
testcase_41 AC 36 ms
53,716 KB
testcase_42 AC 117 ms
73,868 KB
testcase_43 AC 130 ms
74,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

x=int(input())

#x=5*10**5

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

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

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

ANS=0
for b in Primes:
    if b**2>x*2:
        break

    for y in Primes:
        if y>b**2:
            break
        if b**2-y in SP:
            ANS+=1

print(ANS)
0