結果

問題 No.843 Triple Primes
ユーザー Y17Y17
提出日時 2019-06-28 21:57:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 1,278 ms
コンパイル使用メモリ 151,684 KB
実行使用メモリ 9,236 KB
最終ジャッジ日時 2023-09-14 21:56:36
合計ジャッジ時間 5,395 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 118 ms
9,204 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 92 ms
8,308 KB
testcase_08 AC 112 ms
8,508 KB
testcase_09 AC 118 ms
9,164 KB
testcase_10 AC 99 ms
8,320 KB
testcase_11 AC 113 ms
8,828 KB
testcase_12 AC 122 ms
9,032 KB
testcase_13 AC 118 ms
9,016 KB
testcase_14 AC 119 ms
8,904 KB
testcase_15 AC 92 ms
8,256 KB
testcase_16 AC 99 ms
8,328 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 WA -
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 21 ms
5,100 KB
testcase_21 AC 11 ms
4,376 KB
testcase_22 AC 56 ms
6,940 KB
testcase_23 AC 56 ms
6,888 KB
testcase_24 AC 23 ms
5,068 KB
testcase_25 AC 17 ms
4,732 KB
testcase_26 AC 118 ms
9,148 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 121 ms
9,064 KB
testcase_29 AC 26 ms
5,212 KB
testcase_30 AC 121 ms
9,180 KB
testcase_31 AC 7 ms
4,380 KB
testcase_32 AC 4 ms
4,380 KB
testcase_33 AC 29 ms
5,432 KB
testcase_34 AC 50 ms
6,388 KB
testcase_35 AC 119 ms
9,236 KB
testcase_36 AC 14 ms
4,652 KB
testcase_37 AC 89 ms
8,068 KB
testcase_38 AC 67 ms
7,188 KB
testcase_39 AC 121 ms
9,036 KB
testcase_40 WA -
testcase_41 AC 1 ms
4,376 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long

int tbl[500010] = {};
vector<int> so;
set<int> st;

signed main(){
    int n;
    cin >> n;

    for(int i = 2;i <= n;i++){
        if(tbl[i] == 0){
            so.push_back(i);
            st.insert(i);
            for(int j = i*2;j <= n;j+=i){
                tbl[j] = 1;
            }
        }
    }

    int cnt = 0;

    for(int i = 0;i < so.size();i++){
        int rr = so[i]*so[i];
        if(rr > n) break;
        for(int j = 0;j < so.size();j++){
            if(rr-so[j] < 2) break;
            if(st.find(rr-so[j]) != st.end()) cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}





0