結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー Naoyk1212Naoyk1212
提出日時 2016-08-07 21:17:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 618 bytes
コンパイル時間 1,159 ms
コンパイル使用メモリ 148,252 KB
実行使用メモリ 14,468 KB
最終ジャッジ日時 2023-08-22 04:52:33
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 9 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 74 ms
13,128 KB
testcase_06 AC 39 ms
8,388 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 9 ms
4,376 KB
testcase_20 AC 23 ms
5,708 KB
testcase_21 AC 12 ms
4,376 KB
testcase_22 AC 10 ms
4,376 KB
testcase_23 AC 17 ms
5,256 KB
testcase_24 AC 25 ms
5,504 KB
testcase_25 AC 41 ms
8,256 KB
testcase_26 AC 39 ms
8,332 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 19 ms
5,424 KB
testcase_29 AC 39 ms
7,956 KB
testcase_30 AC 8 ms
4,380 KB
testcase_31 AC 33 ms
8,736 KB
testcase_32 AC 40 ms
9,004 KB
testcase_33 AC 79 ms
14,468 KB
testcase_34 AC 76 ms
12,680 KB
testcase_35 AC 70 ms
12,728 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;
  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 + 1);
  long long count = 0;
  for(long long i = 0; i < primes.size(); i++){
    if(primes[i] * (n - 1) <= l){
      count += (l + 1) - (primes[i] * (n - 1));
    }

  }
  cout << count << endl;
}
0