結果

問題 No.732 3PrimeCounting
ユーザー 0w10w1
提出日時 2018-09-09 00:27:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 610 bytes
コンパイル時間 2,122 ms
コンパイル使用メモリ 202,168 KB
実行使用メモリ 10,476 KB
最終ジャッジ日時 2023-08-23 11:14:16
合計ジャッジ時間 45,253 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 16 ms
4,376 KB
testcase_26 AC 10 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 5 ms
4,376 KB
testcase_30 AC 5 ms
4,376 KB
testcase_31 AC 7 ms
4,380 KB
testcase_32 AC 12 ms
4,380 KB
testcase_33 AC 12 ms
4,380 KB
testcase_34 AC 12 ms
4,380 KB
testcase_35 AC 8 ms
4,376 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 9 ms
4,376 KB
testcase_40 AC 8 ms
4,376 KB
testcase_41 AC 8 ms
4,380 KB
testcase_42 AC 7 ms
4,376 KB
testcase_43 AC 5 ms
4,380 KB
testcase_44 AC 5 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 3 ms
4,376 KB
testcase_47 AC 3 ms
4,376 KB
testcase_48 AC 19 ms
4,376 KB
testcase_49 AC 19 ms
4,376 KB
testcase_50 AC 6 ms
4,376 KB
testcase_51 AC 7 ms
4,380 KB
testcase_52 AC 3 ms
4,384 KB
testcase_53 AC 62 ms
4,376 KB
testcase_54 AC 1,384 ms
4,728 KB
testcase_55 AC 1,379 ms
4,704 KB
testcase_56 AC 1,390 ms
4,728 KB
testcase_57 AC 223 ms
4,376 KB
testcase_58 AC 224 ms
4,376 KB
testcase_59 AC 70 ms
4,380 KB
testcase_60 AC 356 ms
4,380 KB
testcase_61 AC 355 ms
4,376 KB
testcase_62 AC 1,859 ms
4,840 KB
testcase_63 AC 730 ms
4,376 KB
testcase_64 AC 480 ms
4,380 KB
testcase_65 AC 478 ms
4,380 KB
testcase_66 AC 2 ms
4,380 KB
testcase_67 AC 2 ms
4,376 KB
testcase_68 AC 1,597 ms
4,808 KB
testcase_69 AC 1,594 ms
4,836 KB
testcase_70 AC 1,410 ms
4,540 KB
testcase_71 AC 1,405 ms
4,600 KB
testcase_72 AC 671 ms
4,376 KB
testcase_73 TLE -
testcase_74 TLE -
testcase_75 AC 16 ms
4,380 KB
testcase_76 AC 1,547 ms
4,812 KB
testcase_77 AC 247 ms
4,376 KB
testcase_78 AC 2,375 ms
5,192 KB
testcase_79 AC 1,619 ms
4,888 KB
testcase_80 AC 2,086 ms
5,336 KB
testcase_81 AC 1,428 ms
4,628 KB
testcase_82 AC 2 ms
4,376 KB
testcase_83 AC 234 ms
4,380 KB
testcase_84 AC 269 ms
4,376 KB
testcase_85 AC 1,170 ms
4,768 KB
testcase_86 AC 2,145 ms
5,240 KB
testcase_87 TLE -
testcase_88 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

signed main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> np(3 * N + 1);
  vector<int> primes;
  for (int i = 2; i <= 3 * N; ++i) {
    if (np[i]) continue;
    primes.emplace_back(i);
    for (int j = i + i; j <= 3 * N; j += i) np[j] = 1;
  }

  long long ans = 0;
  vector<long long> dp(2 * N);
  for (int i = 1; i < primes.size() && primes[i] <= N; ++i) {
    for (int j = 0; j < 2 * N; ++j) if (!np[j + primes[i]]) ans += dp[j];
    for (int j = 0; j < i; ++j) ++dp[primes[i] + primes[j]];
  }

  cout << ans << endl;

  return 0;
}
0