結果

問題 No.732 3PrimeCounting
ユーザー startcppstartcpp
提出日時 2017-01-25 11:56:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 631 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 10,840 KB
実行使用メモリ 15,464 KB
最終ジャッジ日時 2023-08-24 22:04:40
合計ジャッジ時間 10,418 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,148 KB
testcase_01 AC 17 ms
7,896 KB
testcase_02 AC 16 ms
7,904 KB
testcase_03 AC 15 ms
7,768 KB
testcase_04 AC 15 ms
7,908 KB
testcase_05 AC 15 ms
7,764 KB
testcase_06 AC 16 ms
7,832 KB
testcase_07 AC 16 ms
7,776 KB
testcase_08 AC 16 ms
7,792 KB
testcase_09 AC 15 ms
7,728 KB
testcase_10 AC 16 ms
7,856 KB
testcase_11 AC 16 ms
7,768 KB
testcase_12 AC 16 ms
7,836 KB
testcase_13 AC 16 ms
7,764 KB
testcase_14 AC 16 ms
7,784 KB
testcase_15 AC 16 ms
7,892 KB
testcase_16 AC 16 ms
7,888 KB
testcase_17 AC 16 ms
7,784 KB
testcase_18 AC 16 ms
7,896 KB
testcase_19 AC 16 ms
7,836 KB
testcase_20 AC 22 ms
7,780 KB
testcase_21 AC 74 ms
8,220 KB
testcase_22 AC 76 ms
8,236 KB
testcase_23 AC 17 ms
7,724 KB
testcase_24 AC 17 ms
7,844 KB
testcase_25 AC 199 ms
8,276 KB
testcase_26 AC 119 ms
8,272 KB
testcase_27 AC 27 ms
7,792 KB
testcase_28 AC 26 ms
8,272 KB
testcase_29 AC 56 ms
8,284 KB
testcase_30 AC 56 ms
8,304 KB
testcase_31 AC 84 ms
8,280 KB
testcase_32 AC 140 ms
8,340 KB
testcase_33 AC 143 ms
8,296 KB
testcase_34 AC 142 ms
8,280 KB
testcase_35 AC 96 ms
8,208 KB
testcase_36 AC 96 ms
8,316 KB
testcase_37 AC 18 ms
7,832 KB
testcase_38 AC 18 ms
7,768 KB
testcase_39 AC 103 ms
8,408 KB
testcase_40 AC 88 ms
8,244 KB
testcase_41 AC 96 ms
8,416 KB
testcase_42 AC 90 ms
8,268 KB
testcase_43 AC 64 ms
8,300 KB
testcase_44 AC 65 ms
8,332 KB
testcase_45 AC 31 ms
8,188 KB
testcase_46 AC 31 ms
8,276 KB
testcase_47 AC 42 ms
8,252 KB
testcase_48 AC 226 ms
8,368 KB
testcase_49 AC 222 ms
8,576 KB
testcase_50 AC 75 ms
8,188 KB
testcase_51 AC 77 ms
8,416 KB
testcase_52 AC 30 ms
8,232 KB
testcase_53 AC 724 ms
8,520 KB
testcase_54 TLE -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def setPrime(n, is_prime, primes):
	is_prime = [0] * (n + 1)
	for i in range(n + 1):
		is_prime[i] = True
	is_prime[0] = False
	is_prime[1] = False

	for i in range(n + 1):
		if (is_prime[i]):
			j = i * 2
			while (j <= n):
				is_prime[j] = False
				j += i

	for i in range(n + 1):
		if (is_prime[i]):
			primes.append(i)

n = int(input())
is_prime = []
primes = []
cnts = [0] * (3 * n + 1)

setPrime(3 * n, is_prime, primes)
primes2 = primes[:]

ans = 0
for c in primes:
	if (c > n):
		break
	for sum in primes2:
		ans += cnts[sum - c]
	primes2.remove(c)
	for a in primes:
		if (a >= c):
			break
		cnts[a + c] += 1
print(ans)
0