結果

問題 No.732 3PrimeCounting
ユーザー titiatitia
提出日時 2023-05-17 16:33:25
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 915 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 82,564 KB
実行使用メモリ 849,060 KB
最終ジャッジ日時 2024-05-09 02:05:44
合計ジャッジ時間 9,862 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
54,432 KB
testcase_01 AC 43 ms
53,824 KB
testcase_02 AC 42 ms
54,548 KB
testcase_03 AC 43 ms
53,948 KB
testcase_04 AC 43 ms
54,228 KB
testcase_05 AC 43 ms
54,240 KB
testcase_06 AC 42 ms
54,448 KB
testcase_07 AC 44 ms
54,000 KB
testcase_08 AC 43 ms
54,052 KB
testcase_09 AC 42 ms
54,016 KB
testcase_10 AC 42 ms
54,288 KB
testcase_11 AC 43 ms
54,260 KB
testcase_12 AC 42 ms
54,412 KB
testcase_13 AC 43 ms
54,028 KB
testcase_14 AC 43 ms
54,408 KB
testcase_15 AC 42 ms
53,828 KB
testcase_16 AC 43 ms
54,484 KB
testcase_17 AC 43 ms
54,188 KB
testcase_18 AC 42 ms
54,284 KB
testcase_19 AC 43 ms
54,416 KB
testcase_20 AC 59 ms
66,480 KB
testcase_21 AC 102 ms
94,380 KB
testcase_22 AC 101 ms
94,272 KB
testcase_23 AC 52 ms
62,108 KB
testcase_24 AC 51 ms
62,356 KB
testcase_25 AC 167 ms
135,920 KB
testcase_26 AC 125 ms
109,232 KB
testcase_27 AC 65 ms
70,984 KB
testcase_28 AC 65 ms
70,844 KB
testcase_29 AC 85 ms
85,748 KB
testcase_30 AC 85 ms
85,740 KB
testcase_31 AC 108 ms
99,188 KB
testcase_32 AC 139 ms
117,928 KB
testcase_33 AC 141 ms
117,968 KB
testcase_34 AC 138 ms
117,940 KB
testcase_35 AC 117 ms
101,996 KB
testcase_36 AC 115 ms
102,116 KB
testcase_37 AC 55 ms
64,840 KB
testcase_38 AC 55 ms
65,096 KB
testcase_39 AC 118 ms
105,568 KB
testcase_40 AC 112 ms
99,088 KB
testcase_41 AC 109 ms
99,272 KB
testcase_42 AC 108 ms
99,088 KB
testcase_43 AC 97 ms
91,948 KB
testcase_44 AC 97 ms
92,068 KB
testcase_45 AC 68 ms
73,020 KB
testcase_46 AC 69 ms
72,892 KB
testcase_47 AC 77 ms
78,464 KB
testcase_48 AC 179 ms
143,608 KB
testcase_49 AC 181 ms
143,804 KB
testcase_50 AC 106 ms
94,336 KB
testcase_51 AC 104 ms
96,292 KB
testcase_52 AC 68 ms
72,192 KB
testcase_53 AC 425 ms
238,592 KB
testcase_54 MLE -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N=int(input())

x=N*3

# x以下の素数の列挙,素因数分解,約数の列挙
    
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]


PP=[]
MP=[]

for i in range(len(Primes)):
    if Primes[i]>N:
        break
    for j in range(i+1,len(Primes)):
        MP.append(Primes[j]-Primes[i])

C=Counter(MP)

ANS=0

for j in range(len(Primes)):
    if Primes[j]>N:
        break
    for i in range(j+1,len(Primes)):
        C[Primes[i]-Primes[j]]-=1

    #print(Primes[j],C,ANS)

    for i in range(j):
        x=Primes[i]+Primes[j]
        #print(x,C[x])

        ANS+=C[x]

print(ANS)
0