結果

問題 No.843 Triple Primes
ユーザー ManjushriMitraManjushriMitra
提出日時 2024-07-27 12:04:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 782 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 171,188 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-27 12:04:51
合計ジャッジ時間 4,067 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,816 KB
testcase_01 AC 17 ms
6,940 KB
testcase_02 AC 7 ms
6,944 KB
testcase_03 AC 7 ms
6,944 KB
testcase_04 AC 7 ms
6,944 KB
testcase_05 AC 6 ms
6,944 KB
testcase_06 AC 7 ms
6,940 KB
testcase_07 AC 14 ms
6,940 KB
testcase_08 AC 15 ms
6,940 KB
testcase_09 AC 17 ms
6,940 KB
testcase_10 AC 14 ms
6,940 KB
testcase_11 AC 16 ms
6,944 KB
testcase_12 AC 17 ms
6,940 KB
testcase_13 AC 16 ms
6,944 KB
testcase_14 AC 16 ms
6,940 KB
testcase_15 AC 14 ms
6,944 KB
testcase_16 AC 14 ms
6,940 KB
testcase_17 AC 6 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 7 ms
6,940 KB
testcase_20 AC 8 ms
6,940 KB
testcase_21 AC 8 ms
6,944 KB
testcase_22 AC 11 ms
6,944 KB
testcase_23 AC 10 ms
6,944 KB
testcase_24 AC 8 ms
6,944 KB
testcase_25 AC 7 ms
6,940 KB
testcase_26 AC 17 ms
6,944 KB
testcase_27 AC 7 ms
6,940 KB
testcase_28 AC 16 ms
6,940 KB
testcase_29 AC 9 ms
6,940 KB
testcase_30 AC 16 ms
6,940 KB
testcase_31 AC 7 ms
6,940 KB
testcase_32 AC 7 ms
6,944 KB
testcase_33 AC 9 ms
6,940 KB
testcase_34 AC 10 ms
6,940 KB
testcase_35 AC 17 ms
6,940 KB
testcase_36 AC 8 ms
6,944 KB
testcase_37 AC 13 ms
6,940 KB
testcase_38 AC 11 ms
6,940 KB
testcase_39 AC 16 ms
6,944 KB
testcase_40 WA -
testcase_41 AC 7 ms
6,944 KB
testcase_42 AC 15 ms
6,940 KB
testcase_43 AC 15 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<n; ++i)
#define repl(i,m,n) for(ll i=m; i<n; ++i)

int main(){
    int N;
    cin >> N;

    vector<bool> is_prime(500010, true);
    vector<int> prime_list;

    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<=500010; ++i){
        if(!is_prime[i]) continue;
        prime_list.push_back(i);
        for(int j=2*i; j<=500010; j+=i){
            is_prime[j] = false;
        }
    }

    int ans = 0;
    for(int r : prime_list){
        if(r*r >= 2*N || r > N) break;
        for(int p : prime_list){
            if(r*r <= p || p > N) break;
            int q = r*r - p;
            if(is_prime[q] && q <= N) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}
0