結果

問題 No.843 Triple Primes
ユーザー Mcpu3
提出日時 2019-06-29 04:24:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 68,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 05:22:24
合計ジャッジ時間 3,463 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, ans = 0;
	cin >> N;
	vector<bool> a(N + 1, true);
	a[0] = a[1] = false;
	for (int i = 2; i * i <= N; ++i) {
		if (a[i]) {
			for (int j = 2 * i; j <= N; j += i) a[j] = false;
		}
	}
	for (int i = 2; i * i <= N; ++i) {
		for (int j = 2; j < i * i - 1; ++j) {
			if (a[i] && a[i * i - j] && a[j]) ++ans;
		}
	}
	cout << ans;
}
0