結果

問題 No.843 Triple Primes
ユーザー silopysilopy
提出日時 2019-07-07 00:25:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 418 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 11,896 KB
実行使用メモリ 13,956 KB
最終ジャッジ日時 2023-10-19 18:02:02
合計ジャッジ時間 10,555 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,116 KB
testcase_01 AC 416 ms
13,956 KB
testcase_02 AC 32 ms
10,168 KB
testcase_03 AC 31 ms
10,152 KB
testcase_04 AC 33 ms
10,196 KB
testcase_05 AC 32 ms
10,160 KB
testcase_06 AC 34 ms
10,204 KB
testcase_07 AC 321 ms
13,120 KB
testcase_08 AC 359 ms
13,432 KB
testcase_09 AC 412 ms
13,956 KB
testcase_10 AC 338 ms
13,432 KB
testcase_11 AC 376 ms
13,692 KB
testcase_12 AC 400 ms
13,956 KB
testcase_13 AC 387 ms
13,692 KB
testcase_14 AC 384 ms
13,692 KB
testcase_15 AC 330 ms
13,384 KB
testcase_16 AC 334 ms
13,432 KB
testcase_17 AC 29 ms
10,116 KB
testcase_18 AC 29 ms
10,116 KB
testcase_19 AC 29 ms
10,116 KB
testcase_20 AC 110 ms
11,260 KB
testcase_21 AC 72 ms
10,604 KB
testcase_22 AC 216 ms
12,328 KB
testcase_23 AC 228 ms
12,328 KB
testcase_24 AC 117 ms
11,260 KB
testcase_25 AC 94 ms
11,000 KB
testcase_26 AC 418 ms
13,956 KB
testcase_27 AC 44 ms
10,408 KB
testcase_28 AC 399 ms
13,692 KB
testcase_29 AC 124 ms
11,260 KB
testcase_30 AC 408 ms
13,956 KB
testcase_31 AC 54 ms
10,408 KB
testcase_32 AC 43 ms
10,408 KB
testcase_33 AC 133 ms
11,524 KB
testcase_34 AC 198 ms
12,064 KB
testcase_35 AC 415 ms
13,956 KB
testcase_36 AC 86 ms
10,864 KB
testcase_37 AC 315 ms
13,120 KB
testcase_38 AC 258 ms
12,592 KB
testcase_39 AC 404 ms
13,956 KB
testcase_40 AC 29 ms
10,116 KB
testcase_41 AC 30 ms
10,116 KB
testcase_42 AC 345 ms
13,432 KB
testcase_43 AC 381 ms
13,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isPrime(N):
	isp=[True for _ in range(N+1)]
	isp[0],isp[1]=False,False
	for i in range(2,N+1):
		if i*i>N:
			break
		for j in range(2,N+1):
			if i*j>N:
				break
			isp[i*j]=False
	return isp

def main():
	N=int(input())

	isp=isPrime(N)

	ans=0
	for r in range(2,N+1):
		if isp[r]==False:
			continue
		if r*r-2<=N and isp[r*r-2]==True:
			ans+=2
			if r==2:
				ans-=1
	
	print(ans)
	return

main()
0