結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
6,676 KB
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
testcase_26 WA -
testcase_27 AC 2 ms
6,676 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
権限があれば一括ダウンロードができます

ソースコード

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);
    for (int i = 0; primes[i]*(n-1) <= l; i++){
        max1 = primes[i]*(n-1);
        if ((l - max1 + 1)>0) ans += (l - max1 + 1);
    }
    cout << ans << endl;
}
0