結果

問題 No.732 3PrimeCounting
ユーザー startcppstartcpp
提出日時 2017-01-25 11:57:27
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 631 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 6,620 KB
実行使用メモリ 18,636 KB
最終ジャッジ日時 2023-08-24 22:04:50
合計ジャッジ時間 9,289 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,460 KB
testcase_01 AC 11 ms
6,088 KB
testcase_02 AC 10 ms
5,936 KB
testcase_03 AC 10 ms
6,212 KB
testcase_04 AC 10 ms
6,192 KB
testcase_05 AC 11 ms
6,028 KB
testcase_06 AC 10 ms
5,968 KB
testcase_07 AC 10 ms
5,940 KB
testcase_08 AC 11 ms
5,944 KB
testcase_09 AC 11 ms
5,972 KB
testcase_10 AC 11 ms
6,140 KB
testcase_11 AC 11 ms
6,196 KB
testcase_12 AC 10 ms
6,020 KB
testcase_13 AC 11 ms
5,980 KB
testcase_14 AC 10 ms
5,948 KB
testcase_15 AC 10 ms
6,080 KB
testcase_16 AC 11 ms
6,072 KB
testcase_17 AC 10 ms
5,936 KB
testcase_18 AC 11 ms
6,028 KB
testcase_19 AC 11 ms
6,048 KB
testcase_20 AC 15 ms
6,136 KB
testcase_21 AC 54 ms
6,332 KB
testcase_22 AC 54 ms
6,272 KB
testcase_23 AC 11 ms
6,084 KB
testcase_24 AC 12 ms
5,956 KB
testcase_25 AC 146 ms
6,552 KB
testcase_26 AC 87 ms
6,300 KB
testcase_27 AC 19 ms
6,052 KB
testcase_28 AC 19 ms
6,048 KB
testcase_29 AC 39 ms
6,280 KB
testcase_30 AC 40 ms
6,204 KB
testcase_31 AC 62 ms
6,192 KB
testcase_32 AC 104 ms
6,572 KB
testcase_33 AC 106 ms
6,544 KB
testcase_34 AC 106 ms
6,484 KB
testcase_35 AC 71 ms
6,188 KB
testcase_36 AC 70 ms
6,388 KB
testcase_37 AC 14 ms
6,088 KB
testcase_38 AC 14 ms
5,980 KB
testcase_39 AC 76 ms
6,196 KB
testcase_40 AC 66 ms
6,196 KB
testcase_41 AC 66 ms
6,328 KB
testcase_42 AC 66 ms
6,272 KB
testcase_43 AC 47 ms
6,324 KB
testcase_44 AC 48 ms
6,204 KB
testcase_45 AC 23 ms
6,232 KB
testcase_46 AC 22 ms
6,212 KB
testcase_47 AC 29 ms
6,096 KB
testcase_48 AC 165 ms
6,664 KB
testcase_49 AC 165 ms
6,532 KB
testcase_50 AC 56 ms
6,264 KB
testcase_51 AC 57 ms
6,188 KB
testcase_52 AC 22 ms
6,104 KB
testcase_53 AC 532 ms
7,332 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