結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 11 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 102 ms
12,768 KB
testcase_06 AC 52 ms
8,012 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 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 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 RE -
testcase_20 AC 32 ms
5,820 KB
testcase_21 AC 14 ms
5,376 KB
testcase_22 AC 12 ms
5,376 KB
testcase_23 AC 21 ms
5,556 KB
testcase_24 AC 30 ms
5,696 KB
testcase_25 AC 50 ms
8,112 KB
testcase_26 AC 51 ms
7,984 KB
testcase_27 AC 8 ms
5,376 KB
testcase_28 AC 22 ms
5,712 KB
testcase_29 AC 49 ms
8,088 KB
testcase_30 AC 11 ms
5,376 KB
testcase_31 AC 41 ms
7,992 KB
testcase_32 AC 48 ms
8,096 KB
testcase_33 AC 109 ms
12,820 KB
testcase_34 AC 106 ms
12,816 KB
testcase_35 AC 97 ms
12,572 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 count = 0;
  for(long long i = 0; i < primes.size(); i++){
//    cout << primes[i] << endl;
    if(primes[i] * (n - 1) <= l){
      count += (l + 1) - (primes[i] * (n - 1));
    }

  }
  cout << count << endl;
}
0