結果

問題 No.732 3PrimeCounting
ユーザー dama_mathdama_math
提出日時 2018-09-07 22:36:40
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,336 bytes
コンパイル時間 2,709 ms
コンパイル使用メモリ 147,120 KB
実行使用メモリ 4,956 KB
最終ジャッジ日時 2023-08-19 20:34:54
合計ジャッジ時間 15,931 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,452 KB
testcase_01 AC 3 ms
4,568 KB
testcase_02 AC 3 ms
4,504 KB
testcase_03 AC 3 ms
4,508 KB
testcase_04 AC 3 ms
4,448 KB
testcase_05 AC 2 ms
4,636 KB
testcase_06 AC 3 ms
4,452 KB
testcase_07 AC 3 ms
4,508 KB
testcase_08 AC 3 ms
4,624 KB
testcase_09 AC 3 ms
4,552 KB
testcase_10 AC 3 ms
4,424 KB
testcase_11 AC 3 ms
4,684 KB
testcase_12 AC 2 ms
4,636 KB
testcase_13 AC 3 ms
4,508 KB
testcase_14 AC 2 ms
4,684 KB
testcase_15 AC 3 ms
4,508 KB
testcase_16 AC 2 ms
4,520 KB
testcase_17 AC 3 ms
4,532 KB
testcase_18 AC 3 ms
4,624 KB
testcase_19 AC 3 ms
4,516 KB
testcase_20 AC 3 ms
4,624 KB
testcase_21 AC 3 ms
4,708 KB
testcase_22 AC 3 ms
4,564 KB
testcase_23 AC 3 ms
4,520 KB
testcase_24 AC 3 ms
4,524 KB
testcase_25 AC 6 ms
4,696 KB
testcase_26 AC 5 ms
4,436 KB
testcase_27 AC 3 ms
4,460 KB
testcase_28 AC 3 ms
4,516 KB
testcase_29 AC 4 ms
4,564 KB
testcase_30 AC 4 ms
4,568 KB
testcase_31 AC 3 ms
4,512 KB
testcase_32 AC 5 ms
4,468 KB
testcase_33 AC 6 ms
4,524 KB
testcase_34 AC 5 ms
4,524 KB
testcase_35 AC 5 ms
4,516 KB
testcase_36 AC 5 ms
4,520 KB
testcase_37 AC 3 ms
4,636 KB
testcase_38 AC 2 ms
4,820 KB
testcase_39 AC 5 ms
4,540 KB
testcase_40 AC 4 ms
4,572 KB
testcase_41 AC 4 ms
4,516 KB
testcase_42 AC 4 ms
4,576 KB
testcase_43 AC 4 ms
4,456 KB
testcase_44 AC 3 ms
4,816 KB
testcase_45 AC 3 ms
4,512 KB
testcase_46 AC 3 ms
4,640 KB
testcase_47 AC 3 ms
4,536 KB
testcase_48 AC 6 ms
4,572 KB
testcase_49 AC 6 ms
4,628 KB
testcase_50 AC 4 ms
4,512 KB
testcase_51 AC 4 ms
4,456 KB
testcase_52 AC 3 ms
4,816 KB
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 AC 46 ms
4,864 KB
testcase_58 AC 46 ms
4,572 KB
testcase_59 RE -
testcase_60 AC 61 ms
4,752 KB
testcase_61 AC 61 ms
4,564 KB
testcase_62 WA -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 AC 3 ms
4,524 KB
testcase_67 AC 3 ms
4,636 KB
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 AC 585 ms
4,956 KB
testcase_74 WA -
testcase_75 AC 6 ms
4,520 KB
testcase_76 RE -
testcase_77 AC 49 ms
4,624 KB
testcase_78 WA -
testcase_79 RE -
testcase_80 AC 465 ms
4,636 KB
testcase_81 RE -
testcase_82 AC 2 ms
4,524 KB
testcase_83 AC 48 ms
4,624 KB
testcase_84 AC 52 ms
4,652 KB
testcase_85 RE -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

//素数判定
bool pj(int n){
    if(n==1) return false;
    int d=2;
    while(d*d<=n){
        if(n%d==0)return false;
        d++;
    }
    return true;
}

int main(){
    int n; cin>>n;
    vector<int> v;
    int m[300000]={};
    FOR(i,1,3*n+1) if(pj(i)) v.PB(i);
    for(int i=0;v[i]<=n;i++){
        for(int j=0;v[j]<=n;j++){
            m[v[i]+v[j]]++;
        }
    }
    ll ans1=0,ans2=0;
    for(int i=0;v[i]<=3*n;i++){
        for(int j=0;v[j]<=n;j++){
            if(v[i]>v[j]){
                ans1+=m[v[i]-v[j]];
            }
        }
    }
    memset(m,0,sizeof(m));
    for(int i=0;v[i]<=n;i++){
            m[2*v[i]]++;
    }
    for(int i=0;v[i]<=3*n;i++){
        for(int j=0;v[j]<=n;j++){
            if(v[i]>v[j]){
                ans2+=m[v[i]-v[j]];
            }
        }
    }
    co((ans1-ans2*3)/6);
}
0