結果

問題 No.843 Triple Primes
ユーザー ldsybldsyb
提出日時 2019-06-28 22:47:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 167,872 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 22:28:41
合計ジャッジ時間 8,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 256 ms
4,380 KB
testcase_02 AC 2 ms
4,500 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 189 ms
4,376 KB
testcase_08 AC 215 ms
4,376 KB
testcase_09 AC 256 ms
4,380 KB
testcase_10 AC 198 ms
4,380 KB
testcase_11 AC 227 ms
4,380 KB
testcase_12 AC 247 ms
4,380 KB
testcase_13 AC 240 ms
4,380 KB
testcase_14 AC 237 ms
4,376 KB
testcase_15 AC 193 ms
4,376 KB
testcase_16 AC 197 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 42 ms
4,376 KB
testcase_21 AC 19 ms
4,380 KB
testcase_22 AC 114 ms
4,376 KB
testcase_23 AC 119 ms
4,380 KB
testcase_24 AC 46 ms
4,376 KB
testcase_25 AC 32 ms
4,380 KB
testcase_26 AC 254 ms
4,376 KB
testcase_27 AC 7 ms
4,380 KB
testcase_28 AC 242 ms
4,380 KB
testcase_29 AC 49 ms
4,376 KB
testcase_30 AC 249 ms
4,380 KB
testcase_31 AC 11 ms
4,376 KB
testcase_32 AC 6 ms
4,380 KB
testcase_33 AC 57 ms
4,380 KB
testcase_34 AC 100 ms
4,376 KB
testcase_35 AC 256 ms
4,376 KB
testcase_36 AC 27 ms
4,376 KB
testcase_37 AC 180 ms
4,376 KB
testcase_38 AC 140 ms
4,380 KB
testcase_39 AC 244 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 WA -
testcase_42 AC 206 ms
4,380 KB
testcase_43 AC 227 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int64_t n;
	cin >> n;

	vector<int64_t> ps;
	ps.emplace_back(2);
	for (int64_t i = 3; i <= n; i += 2)
	{
		bool f = true;
		for (auto &p : ps)
		{
			if (i < p * p)
			{
				break;
			}
			f &= i % p != 0;
		}
		if (f)
		{
			ps.emplace_back(i);
		}
	}

	int64_t ans = 0;
	for (auto &x : ps)
	{
		int64_t r = x * x;
		auto itr = lower_bound(ps.begin(), ps.end(), r - 2);
		if (itr != ps.end() && (*itr == r - 2))
		{
			ans++;
		}
	}
	ans *= 2;
	ans--;

	cout << ans << endl;

	return 0;
}
0