結果

問題 No.843 Triple Primes
ユーザー ahe100ahe100
提出日時 2019-06-28 21:44:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 168,180 KB
実行使用メモリ 12,320 KB
最終ジャッジ日時 2023-09-14 21:47:42
合計ジャッジ時間 36,221 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,524 KB
testcase_01 AC 1,827 ms
12,292 KB
testcase_02 AC 5 ms
11,812 KB
testcase_03 AC 5 ms
11,740 KB
testcase_04 AC 6 ms
11,796 KB
testcase_05 AC 5 ms
11,760 KB
testcase_06 AC 5 ms
11,816 KB
testcase_07 AC 1,192 ms
11,908 KB
testcase_08 AC 1,436 ms
12,076 KB
testcase_09 AC 1,768 ms
12,080 KB
testcase_10 AC 1,336 ms
11,964 KB
testcase_11 AC 1,610 ms
11,908 KB
testcase_12 AC 1,681 ms
11,932 KB
testcase_13 AC 1,631 ms
12,320 KB
testcase_14 AC 1,646 ms
12,100 KB
testcase_15 AC 1,223 ms
12,016 KB
testcase_16 AC 1,309 ms
11,928 KB
testcase_17 AC 3 ms
7,240 KB
testcase_18 WA -
testcase_19 AC 4 ms
7,260 KB
testcase_20 AC 100 ms
11,924 KB
testcase_21 AC 37 ms
11,892 KB
testcase_22 AC 490 ms
12,184 KB
testcase_23 AC 544 ms
11,916 KB
testcase_24 AC 110 ms
11,852 KB
testcase_25 AC 70 ms
11,972 KB
testcase_26 AC 1,800 ms
12,000 KB
testcase_27 AC 10 ms
11,828 KB
testcase_28 AC 1,676 ms
12,100 KB
testcase_29 AC 124 ms
11,904 KB
testcase_30 AC 1,806 ms
12,100 KB
testcase_31 AC 18 ms
11,924 KB
testcase_32 AC 9 ms
11,832 KB
testcase_33 AC 146 ms
11,904 KB
testcase_34 AC 380 ms
12,000 KB
testcase_35 AC 1,756 ms
11,936 KB
testcase_36 AC 58 ms
11,868 KB
testcase_37 AC 1,102 ms
12,000 KB
testcase_38 AC 715 ms
12,008 KB
testcase_39 AC 1,758 ms
12,068 KB
testcase_40 WA -
testcase_41 AC 3 ms
7,244 KB
testcase_42 AC 1,307 ms
12,100 KB
testcase_43 AC 1,479 ms
11,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n,a[1000010]={},ans=0;
vector<ll> pl;

void prime_list(ll n,vector<ll>& p){
	ll visited[500010]={};
	reg(i,2,n){
		if(visited[i]==0){
			p.push_back(i);
			reg(j,2,n){
				if(j*i>n)break;
				visited[i*j]=1;
			}
		}
	}
}

void init(){
	cin>>n;
	prime_list(n,pl);
	for(ll r:pl){
		if(r*r>1000000)break;
		a[r*r]=r;
	}
}

int main(void){
	init();
	ll m=pl.size();
	cerr<<m<<endl;
	rep(i,m){
		ll p=pl[i];
		rep(j,i){
			ll q=pl[j];
			if(a[p+q]!=0){
				ans++;
				// cerr<<p<<" "<<q<<" "<<a[p+q]<<endl;
			}
		}
	}
	ans*=2;
	if(n>=4)ans++;
	cout<<ans<<endl;
	return 0;
}
0