結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー kpinkcat
提出日時 2023-12-11 03:03:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 752 bytes
コンパイル時間 1,157 ms
コンパイル使用メモリ 105,756 KB
最終ジャッジ日時 2025-02-18 10:16:50
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 RE * 1
other AC * 27 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
using ll = long long;

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n, l, max = 0;
    ll ans = 0;
    cin >> n >> l;
    int MAX = l+1;
    vector<int> p(MAX, 1), primes;
    p[0] = 0;
    p[1] = 0;
    for (int i = 2; i < MAX; i++){
        if (p[i]) primes.push_back(i);
        for (int j = i*2; j < MAX; j += i){
            p[j] = 0;
        }
    }
    for (int i = 0; primes[i]*(n-1) <= l; i++){
        max = primes[i]*(n-1);
        if ((l - max + 1) > 0) ans += (l - max + 1);
    }
    cout << ans << endl;
}
0