結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nenuonnenuon
提出日時 2017-07-04 22:03:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 934 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 90,860 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-15 16:19:08
合計ジャッジ時間 3,686 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
13,184 KB
testcase_01 AC 53 ms
13,312 KB
testcase_02 AC 53 ms
13,440 KB
testcase_03 AC 53 ms
13,292 KB
testcase_04 AC 52 ms
13,312 KB
testcase_05 AC 52 ms
13,204 KB
testcase_06 AC 53 ms
13,312 KB
testcase_07 AC 52 ms
13,056 KB
testcase_08 AC 50 ms
13,056 KB
testcase_09 AC 51 ms
13,184 KB
testcase_10 AC 50 ms
13,312 KB
testcase_11 AC 50 ms
13,328 KB
testcase_12 AC 51 ms
13,312 KB
testcase_13 AC 51 ms
13,184 KB
testcase_14 AC 52 ms
13,224 KB
testcase_15 AC 52 ms
13,264 KB
testcase_16 AC 52 ms
13,184 KB
testcase_17 AC 53 ms
13,224 KB
testcase_18 AC 55 ms
13,056 KB
testcase_19 AC 53 ms
13,056 KB
testcase_20 AC 59 ms
13,312 KB
testcase_21 AC 54 ms
13,308 KB
testcase_22 AC 52 ms
13,184 KB
testcase_23 AC 52 ms
13,244 KB
testcase_24 AC 53 ms
13,440 KB
testcase_25 AC 58 ms
13,420 KB
testcase_26 AC 52 ms
13,312 KB
testcase_27 AC 53 ms
13,236 KB
testcase_28 AC 52 ms
13,184 KB
testcase_29 AC 50 ms
13,312 KB
testcase_30 AC 52 ms
13,184 KB
testcase_31 AC 52 ms
13,312 KB
testcase_32 AC 54 ms
13,320 KB
testcase_33 AC 62 ms
13,232 KB
testcase_34 AC 64 ms
13,312 KB
testcase_35 AC 57 ms
13,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

const ll MAX = 10000000;
bool isPrime[MAX];
vector<ll> prime;
void makePrime(){
  for (ll i = 0; i < MAX; i++){
    isPrime[i] = true;
  }
  for (ll i = 2; i * i < MAX + 1; i++){
    if(isPrime[i]){
      for (ll j = 2 * i; j < MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }
  return;
}
int main(){
  ll N, L;
  cin >> N >> L;
  // L / (N - 1) 以下の素数の個数
  makePrime();
  ll ans = 0;
  FOR(d, 2, MAX){
    if(d * (N - 1) > L) break;
    if(!isPrime[d]) continue;
    if(d * (N - 1) <= L) ans += (L - (d * (N - 1))) + 1;
  }
  cout << ans << endl;
  return 0;
}
0