結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー kk
提出日時 2020-08-08 11:00:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 1,000 ms
コード長 636 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 201,392 KB
実行使用メモリ 8,948 KB
最終ジャッジ日時 2024-04-08 16:27:30
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
8,948 KB
testcase_01 AC 24 ms
8,948 KB
testcase_02 AC 23 ms
8,948 KB
testcase_03 AC 23 ms
8,948 KB
testcase_04 AC 23 ms
8,948 KB
testcase_05 AC 24 ms
8,948 KB
testcase_06 AC 23 ms
8,948 KB
testcase_07 AC 23 ms
8,948 KB
testcase_08 AC 24 ms
8,948 KB
testcase_09 AC 23 ms
8,948 KB
testcase_10 AC 23 ms
8,948 KB
testcase_11 AC 23 ms
8,948 KB
testcase_12 AC 23 ms
8,948 KB
testcase_13 AC 23 ms
8,948 KB
testcase_14 AC 23 ms
8,948 KB
testcase_15 AC 23 ms
8,948 KB
testcase_16 AC 23 ms
8,948 KB
testcase_17 AC 23 ms
8,948 KB
testcase_18 AC 23 ms
8,948 KB
testcase_19 AC 25 ms
8,948 KB
testcase_20 AC 26 ms
8,948 KB
testcase_21 AC 23 ms
8,948 KB
testcase_22 AC 23 ms
8,948 KB
testcase_23 AC 24 ms
8,948 KB
testcase_24 AC 24 ms
8,948 KB
testcase_25 AC 28 ms
8,948 KB
testcase_26 AC 23 ms
8,948 KB
testcase_27 AC 23 ms
8,948 KB
testcase_28 AC 23 ms
8,948 KB
testcase_29 AC 24 ms
8,948 KB
testcase_30 AC 25 ms
8,948 KB
testcase_31 AC 24 ms
8,948 KB
testcase_32 AC 26 ms
8,948 KB
testcase_33 AC 32 ms
8,948 KB
testcase_34 AC 32 ms
8,948 KB
testcase_35 AC 27 ms
8,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

template <size_t N>
void psieve(bool (&p)[N]) {
  for (int i = 0; i < N; i++)
    p[i] = true;
  p[0] = p[1] = false;
  for (int i = 2; i * i < N; i++) {
    if (!p[i])
      continue;
    for (int j = i * i; j < N; j += i)
      p[j] = false;
  }
}

bool pr[5555555];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, l;
  cin >> n >> l;

  psieve(pr);

  long long ret = 0;
  for (int p = 2; p * (n-1) <= l; p++) {
    if (!pr[p]) continue;
    ret += l - p * (n - 1) + 1;
  }

  cout << ret << endl;
  
  return 0;
}
0