結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー Konton7Konton7
提出日時 2020-01-13 19:18:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 890 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 203,760 KB
実行使用メモリ 46,680 KB
最終ジャッジ日時 2023-08-23 11:28:48
合計ジャッジ時間 8,347 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

void shave(vector<int> &v, int n)
{
    vector<int> x, y;
    int n_sq = sqrt(n) + 1;
    for (int i = 3; i < n + 1; i += 2)
    {
        x.push_back(i);
    }
    for (int i = 3; i < n_sq; i += 2)
    {
        for (auto itr = x.begin(); itr != x.end(); itr++)
        {
            if (*itr == i || *itr % i != 0)
                y.push_back(*itr);
        }
        x.clear();
        x = y;
        y.clear();
    }
    if (n >= 2)
        x.insert(x.begin(), 2);

    for (auto itr = x.begin(); itr != x.end(); itr++)
    {
        v.push_back(*itr);
    }
}

int main(){
    int n, l, d;
    cin >> n >> l;
    ll ans = 0;
    vector<int> primes;
    shave(primes, 2*(l+n)/n);

    
    for (int x : primes) {
        d = (n-1) * x;
        ans += max(0, l - d + 1);
    }
    cout << ans << endl;
    return 0;
}
0