結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー tonyu0tonyu0
提出日時 2020-05-17 19:42:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 578 bytes
コンパイル時間 921 ms
コンパイル使用メモリ 100,316 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 12:39:57
合計ジャッジ時間 4,157 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

ll n, l;
int main()
{
  cin >> n >> l;
  vector<ll> prime;
  vector<bool> is_prime(1000010, true);
  for (ll i = 2; i < l; ++i)
  {
    if (is_prime[i])
    {
      prime.push_back(i);
      for (ll j = i + i; j < l; j += i)
      {
        is_prime[j] = false;
      }
    }
  }

  ll ans = 0;
  for (int p : prime)
  {
    ll all = p * ~-n;
    if (all <= l)
    {
      ans += l - all + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
0