結果

問題 No.843 Triple Primes
ユーザー kotamanegikotamanegi
提出日時 2019-06-28 21:28:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,426 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 103,560 KB
実行使用メモリ 8,440 KB
最終ジャッジ日時 2023-09-14 21:36:20
合計ジャッジ時間 2,949 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 12 ms
8,144 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 10 ms
8,024 KB
testcase_08 AC 12 ms
8,440 KB
testcase_09 AC 12 ms
8,116 KB
testcase_10 AC 11 ms
8,244 KB
testcase_11 AC 12 ms
8,184 KB
testcase_12 AC 13 ms
8,256 KB
testcase_13 AC 12 ms
8,164 KB
testcase_14 AC 12 ms
8,136 KB
testcase_15 AC 11 ms
7,692 KB
testcase_16 AC 11 ms
8,228 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 4 ms
4,824 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 8 ms
7,856 KB
testcase_23 AC 8 ms
7,776 KB
testcase_24 AC 4 ms
4,572 KB
testcase_25 AC 4 ms
4,560 KB
testcase_26 AC 12 ms
8,084 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 13 ms
8,180 KB
testcase_29 AC 5 ms
4,944 KB
testcase_30 AC 12 ms
8,188 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 5 ms
4,868 KB
testcase_34 AC 7 ms
5,620 KB
testcase_35 AC 13 ms
8,252 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 10 ms
7,820 KB
testcase_38 AC 9 ms
7,792 KB
testcase_39 AC 13 ms
8,216 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 WA -
testcase_42 AC 12 ms
8,244 KB
testcase_43 AC 12 ms
8,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int is_sosuu[1500000];
int main() {
	long long n;
	cin >> n;
	if (n == 1) {
		cout << "1" << endl;
		return 0;
	}
	vector<long long> sosuu;
	for (int i = 2; i <= 2*n; ++i) {
		if (is_sosuu[i] == 0) {
			sosuu.push_back(i);
			for (int q = 2; i * q <= 2 * n; ++q) {
				is_sosuu[i * q] = 1;
			}
		}
	}
	long long ans = 1;
	for (int i = sosuu.size() - 1; i >= 1; --i) {
		long long now = sosuu[i] * sosuu[i];
		now -= 2;
		if (now >= 0 && now <= n&&is_sosuu[now] == 0) {
			ans += 2;
		}
	}
	cout << ans << endl;
	return 0;
}
0