結果

問題 No.843 Triple Primes
ユーザー takakintakakin
提出日時 2020-05-24 19:11:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-04-20 06:39:00
合計ジャッジ時間 11,039 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 433 ms
16,384 KB
testcase_02 AC 29 ms
10,624 KB
testcase_03 AC 28 ms
10,624 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 30 ms
10,624 KB
testcase_06 AC 29 ms
10,880 KB
testcase_07 AC 326 ms
15,360 KB
testcase_08 AC 360 ms
15,704 KB
testcase_09 AC 444 ms
16,248 KB
testcase_10 AC 344 ms
15,476 KB
testcase_11 AC 368 ms
15,832 KB
testcase_12 AC 409 ms
16,096 KB
testcase_13 AC 387 ms
16,076 KB
testcase_14 AC 377 ms
16,128 KB
testcase_15 AC 305 ms
15,384 KB
testcase_16 AC 316 ms
15,360 KB
testcase_17 AC 27 ms
10,624 KB
testcase_18 WA -
testcase_19 AC 29 ms
10,624 KB
testcase_20 AC 104 ms
12,288 KB
testcase_21 AC 65 ms
11,584 KB
testcase_22 AC 210 ms
14,424 KB
testcase_23 AC 220 ms
14,460 KB
testcase_24 AC 98 ms
12,160 KB
testcase_25 AC 80 ms
12,032 KB
testcase_26 AC 372 ms
16,308 KB
testcase_27 AC 36 ms
11,008 KB
testcase_28 AC 363 ms
16,028 KB
testcase_29 AC 110 ms
12,288 KB
testcase_30 AC 413 ms
16,124 KB
testcase_31 AC 42 ms
11,136 KB
testcase_32 AC 38 ms
11,008 KB
testcase_33 AC 128 ms
12,672 KB
testcase_34 AC 189 ms
14,224 KB
testcase_35 AC 410 ms
16,128 KB
testcase_36 AC 75 ms
11,660 KB
testcase_37 AC 350 ms
14,976 KB
testcase_38 AC 254 ms
14,576 KB
testcase_39 AC 385 ms
16,052 KB
testcase_40 WA -
testcase_41 AC 27 ms
10,752 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

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>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