結果

問題 No.732 3PrimeCounting
コンテスト
ユーザー startcpp
提出日時 2017-01-25 11:51:57
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 70 ms
コンパイル使用メモリ 80,960 KB
実行使用メモリ 86,532 KB
最終ジャッジ日時 2026-10-06 10:44:07
合計ジャッジ時間 8,006 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 89
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 = prime2

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