結果

問題 No.843 Triple Primes
ユーザー bellangeldindonbellangeldindon
提出日時 2019-06-28 22:32:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 389 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 81,872 KB
実行使用メモリ 199,432 KB
最終ジャッジ日時 2023-10-19 17:49:45
合計ジャッジ時間 11,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,480 KB
testcase_01 AC 389 ms
199,432 KB
testcase_02 AC 49 ms
61,856 KB
testcase_03 AC 47 ms
61,856 KB
testcase_04 AC 49 ms
63,904 KB
testcase_05 AC 48 ms
61,856 KB
testcase_06 AC 49 ms
63,904 KB
testcase_07 AC 299 ms
171,584 KB
testcase_08 AC 334 ms
181,548 KB
testcase_09 AC 378 ms
198,640 KB
testcase_10 AC 313 ms
172,640 KB
testcase_11 AC 349 ms
186,564 KB
testcase_12 AC 371 ms
194,680 KB
testcase_13 AC 358 ms
188,676 KB
testcase_14 AC 357 ms
188,676 KB
testcase_15 AC 304 ms
172,376 KB
testcase_16 AC 313 ms
172,640 KB
testcase_17 AC 39 ms
53,420 KB
testcase_18 AC 39 ms
53,480 KB
testcase_19 AC 39 ms
53,480 KB
testcase_20 AC 110 ms
97,732 KB
testcase_21 AC 77 ms
82,152 KB
testcase_22 AC 201 ms
137,596 KB
testcase_23 AC 211 ms
139,180 KB
testcase_24 AC 114 ms
99,316 KB
testcase_25 AC 95 ms
90,604 KB
testcase_26 AC 381 ms
198,640 KB
testcase_27 AC 55 ms
73,436 KB
testcase_28 AC 364 ms
193,624 KB
testcase_29 AC 121 ms
102,484 KB
testcase_30 AC 371 ms
195,208 KB
testcase_31 AC 65 ms
77,836 KB
testcase_32 AC 54 ms
72,760 KB
testcase_33 AC 131 ms
106,972 KB
testcase_34 AC 185 ms
129,940 KB
testcase_35 AC 375 ms
198,640 KB
testcase_36 AC 86 ms
87,428 KB
testcase_37 AC 284 ms
166,832 KB
testcase_38 AC 236 ms
148,948 KB
testcase_39 AC 366 ms
194,416 KB
testcase_40 AC 40 ms
53,480 KB
testcase_41 AC 39 ms
53,420 KB
testcase_42 AC 320 ms
179,964 KB
testcase_43 AC 345 ms
186,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

N = int(input())
if N == 1: print(0)
else:
	prime = []
	numberlist = []
	for i in range(2, N+1):
		numberlist.append(i)
	while numberlist[0] <= int(math.sqrt(N)):
		now = numberlist.pop(0)
		prime.append(now)
		newnumberlist = []
		for i in range(0, len(numberlist)):
			if numberlist[i]%now != 0:
				newnumberlist.append(numberlist[i])
		numberlist = newnumberlist
	prime = prime + numberlist
	sqprime = []
	for i in range(0, len(prime)):
		if prime[i]*prime[i] > 2*prime[-1]: break
		sqprime.append(prime[i]*prime[i])
	cnt = 0
	for i in range(0, len(sqprime)):
		if sqprime[i]-2 in prime:
			if i == 0: cnt += 1
			else: cnt += 2
	print(cnt)
0