結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー CleyLCleyL
提出日時 2022-08-20 19:56:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 628 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 78,176 KB
実行使用メモリ 8,852 KB
最終ジャッジ日時 2024-04-17 17:37:51
合計ジャッジ時間 2,611 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 12 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 112 ms
8,672 KB
testcase_06 AC 62 ms
6,224 KB
testcase_07 AC 1 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 1 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 AC 12 ms
5,376 KB
testcase_20 AC 34 ms
5,376 KB
testcase_21 AC 16 ms
5,376 KB
testcase_22 AC 13 ms
5,376 KB
testcase_23 AC 23 ms
5,376 KB
testcase_24 AC 34 ms
5,376 KB
testcase_25 AC 56 ms
6,068 KB
testcase_26 AC 59 ms
6,060 KB
testcase_27 AC 9 ms
5,376 KB
testcase_28 AC 25 ms
5,376 KB
testcase_29 AC 54 ms
6,044 KB
testcase_30 AC 11 ms
5,376 KB
testcase_31 AC 44 ms
6,064 KB
testcase_32 AC 54 ms
6,052 KB
testcase_33 AC 117 ms
8,728 KB
testcase_34 AC 115 ms
8,852 KB
testcase_35 AC 104 ms
8,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

struct SieveEratos{
  vector<bool> t;
  vector<int> primes;
  SieveEratos(int n):t(n+1,true){
    t[0] = t[1] = false;
    for(int i = 2; n >= i; i++){
      if(t[i]){
        primes.emplace_back(i);
        for(int j = i+i; n >= j; j+=i){
          t[j] = false;
        }
      }
    }
  }
  bool operator[](int x){return t[x];}
};


int main(){
    long long n,l;cin>>n>>l;
    SieveEratos P(l+1);
    long long ans = 0;
    for(long long i = 2; l >= i; i++){
        if(P[i]){
            ans += max(0LL,l-((n-1)*i)+1);
        }
    }
    cout << ans << endl;
}

0