結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー Naoyk1212Naoyk1212
提出日時 2016-08-06 11:22:17
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 671 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 162,928 KB
実行使用メモリ 12,820 KB
最終ジャッジ日時 2024-04-24 18:14:41
合計ジャッジ時間 4,292 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 12 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 112 ms
12,768 KB
testcase_06 AC 58 ms
8,008 KB
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 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 RE -
testcase_20 AC 33 ms
5,820 KB
testcase_21 AC 16 ms
5,376 KB
testcase_22 AC 13 ms
5,376 KB
testcase_23 AC 23 ms
5,560 KB
testcase_24 AC 33 ms
5,692 KB
testcase_25 AC 55 ms
8,116 KB
testcase_26 AC 55 ms
7,872 KB
testcase_27 AC 9 ms
5,376 KB
testcase_28 AC 25 ms
5,716 KB
testcase_29 AC 54 ms
8,092 KB
testcase_30 AC 12 ms
5,376 KB
testcase_31 AC 46 ms
8,116 KB
testcase_32 AC 54 ms
8,020 KB
testcase_33 AC 117 ms
12,820 KB
testcase_34 AC 118 ms
12,820 KB
testcase_35 AC 105 ms
12,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<long long> primes;

void sieve(long long n){
  vector<bool> isPrime(n, true);
  isPrime[0] = false;
  isPrime[1] = false;
  long long maxn = sqrt(n);
  for(long long i = 2; i <= n; i++){
    if(isPrime[i] == true){
      primes.push_back(i);
      for(long long j = i * 2; j <= n; j += i){
        isPrime[j] = false;
      }
    }
  }
}

int main(){
  long long n, l;
  cin >> n >> l;
  sieve(l);
  long long maxspace = l / (n - 1);
  long long count = 0;
  for(int i = 0; i < primes.size(); i++){
    if(primes[i] * (n - 1) <= l){
      count += (l + 1) - (primes[i] * (n - 1));
    }
  }
  cout << count << endl;
}
0