結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 36 ms
7,596 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 TLE -
testcase_06 AC 492 ms
25,944 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 3 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 38 ms
7,732 KB
testcase_20 AC 165 ms
16,164 KB
testcase_21 AC 51 ms
8,988 KB
testcase_22 AC 41 ms
8,052 KB
testcase_23 AC 88 ms
11,992 KB
testcase_24 AC 161 ms
16,164 KB
testcase_25 AC 442 ms
25,000 KB
testcase_26 AC 483 ms
25,000 KB
testcase_27 AC 26 ms
6,548 KB
testcase_28 AC 96 ms
12,888 KB
testcase_29 AC 403 ms
24,376 KB
testcase_30 AC 33 ms
7,296 KB
testcase_31 AC 285 ms
21,044 KB
testcase_32 AC 409 ms
24,648 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

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