結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー kpinkcatkpinkcat
提出日時 2023-12-11 04:35:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 348 ms / 1,000 ms
コード長 840 bytes
コンパイル時間 1,211 ms
コンパイル使用メモリ 110,408 KB
実行使用メモリ 25,000 KB
最終ジャッジ日時 2023-12-11 04:35:21
合計ジャッジ時間 3,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 5 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 17 ms
6,676 KB
testcase_20 AC 57 ms
9,684 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 113 ms
14,212 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 45 ms
8,620 KB
testcase_33 AC 348 ms
25,000 KB
testcase_34 AC 306 ms
25,000 KB
testcase_35 AC 100 ms
13,276 KB
権限があれば一括ダウンロードができます

ソースコード

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, max1 = 0;
    ll ans = 0;
    cin >> n >> l;
    int MAX = max(1, l/(n-1));
    vector<int> p(MAX+1, 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;
        }
    }
    if (!primes.size()) primes.push_back(MAX+2);
    for (int i = 0; primes[i]*(n-1) <= l && i < primes.size(); i++){
        max1 = primes[i]*(n-1);
        if ((l - max1 + 1)>0) ans += (l - max1 + 1);
    }
    cout << ans << endl;
}
0