結果

問題 No.843 Triple Primes
ユーザー takakintakakin
提出日時 2020-05-24 19:15:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 74,960 KB
最終ジャッジ日時 2024-04-20 06:44:11
合計ジャッジ時間 4,585 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,712 KB
testcase_01 AC 121 ms
74,956 KB
testcase_02 AC 40 ms
60,680 KB
testcase_03 AC 43 ms
61,060 KB
testcase_04 AC 41 ms
60,712 KB
testcase_05 AC 40 ms
60,176 KB
testcase_06 AC 40 ms
60,520 KB
testcase_07 AC 84 ms
71,220 KB
testcase_08 AC 95 ms
72,588 KB
testcase_09 AC 112 ms
73,828 KB
testcase_10 AC 87 ms
71,684 KB
testcase_11 AC 96 ms
73,680 KB
testcase_12 AC 108 ms
74,960 KB
testcase_13 AC 101 ms
73,808 KB
testcase_14 AC 101 ms
72,792 KB
testcase_15 AC 85 ms
71,972 KB
testcase_16 AC 86 ms
71,148 KB
testcase_17 AC 36 ms
52,768 KB
testcase_18 AC 36 ms
52,568 KB
testcase_19 AC 36 ms
52,260 KB
testcase_20 AC 48 ms
63,768 KB
testcase_21 AC 61 ms
61,964 KB
testcase_22 AC 85 ms
68,052 KB
testcase_23 AC 84 ms
70,528 KB
testcase_24 AC 51 ms
64,536 KB
testcase_25 AC 50 ms
64,192 KB
testcase_26 AC 109 ms
74,264 KB
testcase_27 AC 40 ms
61,972 KB
testcase_28 AC 99 ms
72,844 KB
testcase_29 AC 50 ms
64,964 KB
testcase_30 AC 108 ms
74,156 KB
testcase_31 AC 41 ms
61,468 KB
testcase_32 AC 41 ms
61,468 KB
testcase_33 AC 52 ms
64,912 KB
testcase_34 AC 62 ms
67,772 KB
testcase_35 AC 109 ms
74,916 KB
testcase_36 AC 47 ms
62,920 KB
testcase_37 AC 79 ms
70,792 KB
testcase_38 AC 67 ms
69,184 KB
testcase_39 AC 103 ms
73,476 KB
testcase_40 AC 35 ms
52,620 KB
testcase_41 AC 34 ms
52,996 KB
testcase_42 AC 86 ms
72,192 KB
testcase_43 AC 96 ms
72,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())

def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]
ans=0
P=primes(n)
SP=set(P)
for p in P:
  if p**2>2*n:
    break
  else:
    for q in P:
      if 2*q>p**2:
        break
      else:
        if p**2-q in SP:
          ans+=1
          if 2*q!=p**2:
            ans+=1
print(ans)
0