結果

問題 No.843 Triple Primes
ユーザー 双六双六
提出日時 2020-07-22 16:33:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 90,108 KB
最終ジャッジ日時 2023-09-02 21:35:37
合計ジャッジ時間 9,839 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
89,528 KB
testcase_01 AC 149 ms
89,552 KB
testcase_02 AC 153 ms
89,600 KB
testcase_03 AC 155 ms
89,768 KB
testcase_04 AC 155 ms
89,796 KB
testcase_05 AC 153 ms
89,772 KB
testcase_06 AC 150 ms
89,792 KB
testcase_07 AC 152 ms
89,724 KB
testcase_08 AC 151 ms
89,772 KB
testcase_09 AC 152 ms
89,812 KB
testcase_10 AC 152 ms
89,732 KB
testcase_11 AC 153 ms
89,580 KB
testcase_12 AC 154 ms
89,944 KB
testcase_13 AC 153 ms
89,940 KB
testcase_14 AC 154 ms
89,944 KB
testcase_15 AC 155 ms
89,616 KB
testcase_16 AC 152 ms
89,736 KB
testcase_17 AC 132 ms
89,744 KB
testcase_18 AC 132 ms
89,744 KB
testcase_19 AC 132 ms
89,580 KB
testcase_20 AC 152 ms
89,788 KB
testcase_21 AC 153 ms
89,776 KB
testcase_22 AC 153 ms
89,608 KB
testcase_23 AC 149 ms
89,732 KB
testcase_24 AC 153 ms
89,936 KB
testcase_25 AC 151 ms
89,732 KB
testcase_26 AC 148 ms
89,552 KB
testcase_27 AC 150 ms
89,552 KB
testcase_28 AC 152 ms
89,764 KB
testcase_29 AC 152 ms
89,952 KB
testcase_30 AC 153 ms
89,828 KB
testcase_31 AC 152 ms
89,948 KB
testcase_32 AC 149 ms
89,808 KB
testcase_33 AC 150 ms
89,772 KB
testcase_34 AC 151 ms
89,804 KB
testcase_35 AC 151 ms
90,108 KB
testcase_36 AC 150 ms
89,828 KB
testcase_37 AC 152 ms
89,900 KB
testcase_38 AC 151 ms
89,556 KB
testcase_39 AC 150 ms
89,756 KB
testcase_40 AC 130 ms
89,576 KB
testcase_41 AC 130 ms
89,576 KB
testcase_42 AC 150 ms
89,948 KB
testcase_43 AC 151 ms
89,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

num = 10 ** 6 + 1 #適当に値を入れる
L = [1 for i in range(num)]; L[0] = 0; L[1] = 0
plist = []
for i in range(num):
	if L[i] == 1:
		plist.append(i); c = 2
		while i * c <= num - 1:
			L[i * c] = 0; c += 1

#処理内容
def main():
	N = int(input())
	ans = 0
	for r in plist:
		if r > N or r ** 2 > 10 ** 6:
			break
		for p in plist:
			if p >= r ** 2:
				break
			q = r ** 2 - p
			if L[q] == 1 and p <= N and q <= N:
				# print(p, r**2-p, r, r**2)
				ans += 1

	print(ans)





if __name__ == '__main__':
	main()
0