結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー kpinkcatkpinkcat
提出日時 2023-12-11 03:50:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 826 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 109,896 KB
実行使用メモリ 25,000 KB
最終ジャッジ日時 2023-12-11 03:50:50
合計ジャッジ時間 3,640 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 4 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 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 1 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 RE -
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 16 ms
6,676 KB
testcase_20 AC 58 ms
9,684 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 RE -
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 97 ms
14,212 KB
testcase_26 RE -
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 AC 1 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 1 ms
6,676 KB
testcase_32 AC 44 ms
8,620 KB
testcase_33 AC 285 ms
25,000 KB
testcase_34 AC 278 ms
25,000 KB
testcase_35 AC 90 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, max = 0;
    ll ans = 0;
    cin >> n >> l;
    int MAX = (l+1)/(n-1) + 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;
        }
    }
    if (!primes.size()) primes.push_back(MAX);
    for (int i = 0; (primes[i]*(n-1) <= l) && primes[i]; i++){
        max = primes[i]*(n-1);
        if ((l - max + 1)>0) ans += (l - max + 1);
    }
    cout << ans << endl;
}
0