結果

問題 No.732 3PrimeCounting
ユーザー titiatitia
提出日時 2023-05-18 00:47:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,724 ms / 3,000 ms
コード長 704 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 83,344 KB
最終ジャッジ日時 2023-08-22 01:52:53
合計ジャッジ時間 31,251 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,928 KB
testcase_01 AC 86 ms
71,960 KB
testcase_02 AC 86 ms
71,628 KB
testcase_03 AC 88 ms
71,712 KB
testcase_04 AC 84 ms
71,980 KB
testcase_05 AC 85 ms
71,956 KB
testcase_06 AC 85 ms
71,492 KB
testcase_07 AC 86 ms
71,836 KB
testcase_08 AC 89 ms
71,652 KB
testcase_09 AC 87 ms
71,644 KB
testcase_10 AC 87 ms
71,628 KB
testcase_11 AC 88 ms
71,764 KB
testcase_12 AC 86 ms
71,844 KB
testcase_13 AC 85 ms
71,488 KB
testcase_14 AC 85 ms
71,680 KB
testcase_15 AC 87 ms
71,652 KB
testcase_16 AC 88 ms
71,632 KB
testcase_17 AC 87 ms
71,708 KB
testcase_18 AC 87 ms
71,812 KB
testcase_19 AC 85 ms
71,664 KB
testcase_20 AC 100 ms
77,224 KB
testcase_21 AC 101 ms
77,396 KB
testcase_22 AC 102 ms
77,716 KB
testcase_23 AC 92 ms
76,952 KB
testcase_24 AC 94 ms
76,888 KB
testcase_25 AC 113 ms
77,820 KB
testcase_26 AC 106 ms
77,808 KB
testcase_27 AC 103 ms
77,228 KB
testcase_28 AC 100 ms
77,092 KB
testcase_29 AC 104 ms
77,728 KB
testcase_30 AC 103 ms
77,760 KB
testcase_31 AC 107 ms
77,504 KB
testcase_32 AC 108 ms
77,872 KB
testcase_33 AC 107 ms
77,944 KB
testcase_34 AC 105 ms
77,932 KB
testcase_35 AC 105 ms
77,844 KB
testcase_36 AC 102 ms
77,744 KB
testcase_37 AC 96 ms
77,332 KB
testcase_38 AC 95 ms
77,276 KB
testcase_39 AC 103 ms
77,788 KB
testcase_40 AC 102 ms
77,724 KB
testcase_41 AC 103 ms
77,584 KB
testcase_42 AC 104 ms
77,772 KB
testcase_43 AC 105 ms
77,812 KB
testcase_44 AC 108 ms
77,728 KB
testcase_45 AC 98 ms
77,272 KB
testcase_46 AC 100 ms
77,144 KB
testcase_47 AC 100 ms
77,688 KB
testcase_48 AC 107 ms
77,648 KB
testcase_49 AC 106 ms
77,820 KB
testcase_50 AC 103 ms
77,560 KB
testcase_51 AC 102 ms
77,892 KB
testcase_52 AC 96 ms
77,348 KB
testcase_53 AC 121 ms
77,940 KB
testcase_54 AC 627 ms
80,428 KB
testcase_55 AC 634 ms
80,416 KB
testcase_56 AC 631 ms
79,928 KB
testcase_57 AC 190 ms
78,472 KB
testcase_58 AC 192 ms
78,880 KB
testcase_59 AC 126 ms
77,856 KB
testcase_60 AC 230 ms
78,944 KB
testcase_61 AC 234 ms
78,924 KB
testcase_62 AC 804 ms
80,528 KB
testcase_63 AC 369 ms
79,504 KB
testcase_64 AC 284 ms
79,004 KB
testcase_65 AC 286 ms
79,112 KB
testcase_66 AC 95 ms
76,960 KB
testcase_67 AC 95 ms
77,048 KB
testcase_68 AC 710 ms
80,624 KB
testcase_69 AC 701 ms
80,776 KB
testcase_70 AC 644 ms
80,128 KB
testcase_71 AC 643 ms
80,364 KB
testcase_72 AC 353 ms
79,528 KB
testcase_73 AC 1,274 ms
82,360 KB
testcase_74 AC 1,269 ms
82,488 KB
testcase_75 AC 106 ms
77,968 KB
testcase_76 AC 687 ms
80,576 KB
testcase_77 AC 198 ms
78,692 KB
testcase_78 AC 999 ms
81,512 KB
testcase_79 AC 725 ms
80,628 KB
testcase_80 AC 909 ms
81,040 KB
testcase_81 AC 657 ms
79,980 KB
testcase_82 AC 101 ms
77,608 KB
testcase_83 AC 193 ms
78,508 KB
testcase_84 AC 206 ms
78,736 KB
testcase_85 AC 559 ms
80,124 KB
testcase_86 AC 931 ms
81,204 KB
testcase_87 AC 1,724 ms
83,292 KB
testcase_88 AC 1,703 ms
83,344 KB
権限があれば一括ダウンロードができます

ソースコード

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]

COUNT=[0]*(N*3+1)
ANS=0

for i in range(len(Primes)):
    if Primes[i]>N:
        break
    for j in range(len(Primes)):
        ANS+=COUNT[Primes[j]-Primes[i]]

    for j in range(i):
        COUNT[Primes[i]+Primes[j]]+=1

print(ANS)
0