結果

問題 No.843 Triple Primes
ユーザー eQeeQe
提出日時 2020-05-06 12:25:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 980 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 90,100 KB
最終ジャッジ日時 2023-09-10 22:11:56
合計ジャッジ時間 13,871 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
85,588 KB
testcase_01 AC 409 ms
89,624 KB
testcase_02 AC 122 ms
89,708 KB
testcase_03 AC 120 ms
89,952 KB
testcase_04 AC 120 ms
90,016 KB
testcase_05 AC 119 ms
89,976 KB
testcase_06 AC 122 ms
90,100 KB
testcase_07 AC 332 ms
89,752 KB
testcase_08 AC 356 ms
89,884 KB
testcase_09 AC 403 ms
89,492 KB
testcase_10 AC 344 ms
89,916 KB
testcase_11 AC 375 ms
89,880 KB
testcase_12 AC 393 ms
89,884 KB
testcase_13 AC 384 ms
89,740 KB
testcase_14 AC 383 ms
89,488 KB
testcase_15 AC 335 ms
89,600 KB
testcase_16 AC 340 ms
89,816 KB
testcase_17 AC 114 ms
85,688 KB
testcase_18 AC 113 ms
85,696 KB
testcase_19 AC 116 ms
85,816 KB
testcase_20 AC 171 ms
89,884 KB
testcase_21 AC 142 ms
89,720 KB
testcase_22 AC 250 ms
89,800 KB
testcase_23 AC 256 ms
89,816 KB
testcase_24 AC 175 ms
89,464 KB
testcase_25 AC 161 ms
89,828 KB
testcase_26 AC 402 ms
89,492 KB
testcase_27 AC 125 ms
90,060 KB
testcase_28 AC 389 ms
89,748 KB
testcase_29 AC 178 ms
89,824 KB
testcase_30 AC 398 ms
89,888 KB
testcase_31 AC 130 ms
90,000 KB
testcase_32 AC 125 ms
89,872 KB
testcase_33 AC 188 ms
89,808 KB
testcase_34 AC 236 ms
89,892 KB
testcase_35 AC 402 ms
89,648 KB
testcase_36 AC 152 ms
89,600 KB
testcase_37 AC 321 ms
89,744 KB
testcase_38 AC 277 ms
89,660 KB
testcase_39 AC 387 ms
89,816 KB
testcase_40 AC 115 ms
85,332 KB
testcase_41 AC 114 ms
85,864 KB
testcase_42 AC 351 ms
89,496 KB
testcase_43 AC 373 ms
89,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from math import sqrt
import sys
from collections import deque, defaultdict
from heapq import heappop,heappush
from copy import deepcopy

INF=10**18
MOD=10**9+7
MAX=10**5+7

isp=[1]*MAX*5*2
def eratos(n):
  global isp
  isp[0]=isp[1]=0
  for i in range(2, int(sqrt(n)+1)):
    if isp[i]==0: continue
    for j in range(i+i, n+1, i):
      isp[j]=0    

def main():
  global isp
  N=int(input())
  eratos(N*2)

  ans=0
  for r in range(min(N+1, int(sqrt(N*2)+1))):
    if isp[r]==0: continue
    for p in range(N+1):
      if isp[p]==0: continue
      q=r*r-p
      if 0<q<=N and isp[q]==1:
        ans+=1
        
  print(ans)

if __name__=='__main__':
  main()



0