結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー saltcandy123saltcandy123
提出日時 2016-08-05 22:45:05
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 513 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 61,636 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 15:56:30
合計ジャッジ時間 2,418 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  int n, l;
  std::vector<bool> is_prime(5000001, true);
  long long count = 0;
  std::cin >> n >> l;
  is_prime[0] = is_prime[1] = false;
  for (int p = 2; p <= l; ++p) {
    if (is_prime[p]) {
      for (int k = 2; k * p <= l; ++k) {
        is_prime[k * p] = false;
      }
      count += std::max(0, l - (n - 1) * p + 1);
    }
  }
  std::cout << count << std::endl;
  return 0;
}
0