結果

問題 No.843 Triple Primes
ユーザー 👑 kmjpkmjp
提出日時 2019-06-29 00:29:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,210 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 168,192 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2023-09-14 22:53:32
合計ジャッジ時間 20,327 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,848 KB
testcase_01 AC 907 ms
7,968 KB
testcase_02 AC 14 ms
7,908 KB
testcase_03 AC 14 ms
8,100 KB
testcase_04 AC 15 ms
7,968 KB
testcase_05 AC 15 ms
7,848 KB
testcase_06 AC 15 ms
7,908 KB
testcase_07 AC 614 ms
7,964 KB
testcase_08 AC 720 ms
8,092 KB
testcase_09 AC 898 ms
7,968 KB
testcase_10 AC 660 ms
8,088 KB
testcase_11 AC 780 ms
7,892 KB
testcase_12 AC 866 ms
8,104 KB
testcase_13 AC 820 ms
7,904 KB
testcase_14 AC 822 ms
8,172 KB
testcase_15 AC 630 ms
7,972 KB
testcase_16 AC 648 ms
8,192 KB
testcase_17 AC 14 ms
8,092 KB
testcase_18 WA -
testcase_19 AC 14 ms
7,972 KB
testcase_20 AC 98 ms
7,908 KB
testcase_21 AC 43 ms
7,852 KB
testcase_22 AC 320 ms
8,008 KB
testcase_23 AC 343 ms
8,076 KB
testcase_24 AC 107 ms
7,912 KB
testcase_25 AC 71 ms
8,088 KB
testcase_26 AC 895 ms
7,892 KB
testcase_27 AC 20 ms
7,908 KB
testcase_28 AC 843 ms
8,036 KB
testcase_29 AC 119 ms
8,032 KB
testcase_30 AC 875 ms
8,032 KB
testcase_31 AC 27 ms
7,848 KB
testcase_32 AC 18 ms
7,968 KB
testcase_33 AC 140 ms
8,180 KB
testcase_34 AC 277 ms
7,972 KB
testcase_35 AC 902 ms
8,096 KB
testcase_36 AC 60 ms
8,076 KB
testcase_37 AC 573 ms
8,048 KB
testcase_38 AC 422 ms
7,896 KB
testcase_39 AC 847 ms
8,088 KB
testcase_40 WA -
testcase_41 AC 14 ms
7,860 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

const int prime_max = 1000000;
vector<int> prime;
int ok[505050];
int NP,divp[prime_max];

void cprime() {
	if(NP) return;
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		if(1LL*i*i<=500000) ok[1LL*i*i]=1;
		prime.push_back(i); NP++;
		for(ll j=1LL*i*i;j>=i&&j<prime_max;j+=i) if(divp[j]==0) divp[j]=i;
	}
}

int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cprime();
	ll ret=0;
	
	cin>>N;
	FOR(i,NP) if(prime[i]<=N) {
		FOR(j,NP) {
			if(prime[i]+prime[j]>N) break;
			if(ok[prime[i]+prime[j]]) ret++;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0