結果

問題 No.732 3PrimeCounting
ユーザー 👑 kmjpkmjp
提出日時 2018-09-08 22:23:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 131 ms / 3,000 ms
コード長 1,224 bytes
コンパイル時間 1,461 ms
コンパイル使用メモリ 147,148 KB
実行使用メモリ 8,468 KB
最終ジャッジ日時 2023-08-23 07:05:50
合計ジャッジ時間 8,133 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
7,632 KB
testcase_01 AC 12 ms
7,640 KB
testcase_02 AC 12 ms
7,568 KB
testcase_03 AC 13 ms
7,640 KB
testcase_04 AC 13 ms
7,700 KB
testcase_05 AC 12 ms
7,632 KB
testcase_06 AC 13 ms
7,572 KB
testcase_07 AC 13 ms
7,564 KB
testcase_08 AC 12 ms
7,568 KB
testcase_09 AC 13 ms
7,636 KB
testcase_10 AC 13 ms
7,712 KB
testcase_11 AC 12 ms
7,680 KB
testcase_12 AC 13 ms
7,632 KB
testcase_13 AC 12 ms
7,632 KB
testcase_14 AC 13 ms
7,628 KB
testcase_15 AC 12 ms
7,652 KB
testcase_16 AC 13 ms
7,572 KB
testcase_17 AC 12 ms
7,700 KB
testcase_18 AC 13 ms
7,576 KB
testcase_19 AC 13 ms
7,652 KB
testcase_20 AC 13 ms
7,640 KB
testcase_21 AC 13 ms
7,788 KB
testcase_22 AC 13 ms
7,648 KB
testcase_23 AC 13 ms
7,560 KB
testcase_24 AC 13 ms
7,640 KB
testcase_25 AC 13 ms
7,600 KB
testcase_26 AC 13 ms
7,660 KB
testcase_27 AC 13 ms
7,564 KB
testcase_28 AC 13 ms
7,636 KB
testcase_29 AC 13 ms
7,660 KB
testcase_30 AC 13 ms
7,588 KB
testcase_31 AC 13 ms
7,792 KB
testcase_32 AC 14 ms
7,884 KB
testcase_33 AC 13 ms
7,740 KB
testcase_34 AC 13 ms
7,672 KB
testcase_35 AC 14 ms
7,608 KB
testcase_36 AC 13 ms
7,652 KB
testcase_37 AC 13 ms
7,696 KB
testcase_38 AC 13 ms
7,592 KB
testcase_39 AC 13 ms
7,728 KB
testcase_40 AC 13 ms
7,672 KB
testcase_41 AC 13 ms
7,592 KB
testcase_42 AC 13 ms
7,580 KB
testcase_43 AC 13 ms
7,924 KB
testcase_44 AC 13 ms
7,932 KB
testcase_45 AC 13 ms
7,720 KB
testcase_46 AC 13 ms
7,864 KB
testcase_47 AC 13 ms
7,728 KB
testcase_48 AC 13 ms
7,664 KB
testcase_49 AC 13 ms
7,608 KB
testcase_50 AC 13 ms
7,656 KB
testcase_51 AC 13 ms
7,660 KB
testcase_52 AC 13 ms
7,724 KB
testcase_53 AC 15 ms
7,932 KB
testcase_54 AC 51 ms
7,996 KB
testcase_55 AC 50 ms
8,104 KB
testcase_56 AC 51 ms
8,124 KB
testcase_57 AC 19 ms
7,816 KB
testcase_58 AC 19 ms
7,740 KB
testcase_59 AC 15 ms
7,724 KB
testcase_60 AC 23 ms
7,796 KB
testcase_61 AC 23 ms
7,784 KB
testcase_62 AC 63 ms
8,352 KB
testcase_63 AC 34 ms
8,200 KB
testcase_64 AC 26 ms
8,012 KB
testcase_65 AC 27 ms
7,880 KB
testcase_66 AC 13 ms
7,632 KB
testcase_67 AC 12 ms
7,704 KB
testcase_68 AC 56 ms
8,040 KB
testcase_69 AC 56 ms
8,108 KB
testcase_70 AC 52 ms
8,004 KB
testcase_71 AC 51 ms
8,004 KB
testcase_72 AC 32 ms
7,920 KB
testcase_73 AC 97 ms
8,284 KB
testcase_74 AC 97 ms
8,232 KB
testcase_75 AC 13 ms
7,684 KB
testcase_76 AC 56 ms
8,088 KB
testcase_77 AC 20 ms
7,744 KB
testcase_78 AC 78 ms
8,468 KB
testcase_79 AC 57 ms
8,096 KB
testcase_80 AC 68 ms
8,184 KB
testcase_81 AC 53 ms
8,208 KB
testcase_82 AC 13 ms
7,584 KB
testcase_83 AC 20 ms
7,860 KB
testcase_84 AC 21 ms
7,752 KB
testcase_85 AC 46 ms
7,956 KB
testcase_86 AC 70 ms
8,116 KB
testcase_87 AC 130 ms
8,356 KB
testcase_88 AC 131 ms
8,436 KB
権限があれば一括ダウンロードができます

ソースコード

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;
int NP,prime[100000],divp[prime_max];
map<int,int> M;

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

int N;
int cnt[303030];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cprime();
	
	ll ret=0;
	int a,b,c;
	for(c=2;prime[c]<=N;c++) {
		b=c-1;
		FOR(a,b) cnt[prime[a]+prime[b]]++;
		for(y=c+1;prime[y]<=prime[c]*3;y++) ret+=cnt[prime[y]-prime[c]];
	}
	
	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