結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー kpinkcatkpinkcat
提出日時 2023-12-11 02:51:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 732 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 108,364 KB
実行使用メモリ 42,356 KB
最終ジャッジ日時 2023-12-11 02:51:24
合計ジャッジ時間 11,420 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 33 ms
7,064 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 TLE -
testcase_06 AC 484 ms
23,768 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 3 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 3 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 39 ms
7,200 KB
testcase_20 AC 165 ms
15,012 KB
testcase_21 AC 50 ms
8,456 KB
testcase_22 AC 38 ms
7,520 KB
testcase_23 AC 70 ms
10,840 KB
testcase_24 AC 154 ms
15,012 KB
testcase_25 AC 461 ms
22,824 KB
testcase_26 AC 465 ms
22,824 KB
testcase_27 AC 25 ms
6,676 KB
testcase_28 AC 103 ms
11,736 KB
testcase_29 AC 415 ms
22,200 KB
testcase_30 AC 32 ms
6,784 KB
testcase_31 AC 274 ms
18,868 KB
testcase_32 AC 478 ms
22,472 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()
{
    int n, l, max = 0;
    ll ans = 0;
    cin >> n >> l;
    int MAX = l+1;
    vector<int> p(MAX, 1);
    p[0] = 0;
    p[1] = 0;
    for (int i = 2; i < MAX; i++){
        for (int j = i*2; j < MAX; j += i){
            p[j] = 0;
        }
    }
    max = 2*(n-1);
    if ((l - max + 1) > 0) ans += (l - max + 1);
    for (int i = 3; i*(n-1) < MAX; i+=2){
        if (p[i]) {
            max = i*(n-1);
            if ((l - max + 1) > 0) ans += (l - max + 1);
        }
    }
    cout << ans << endl;
}
0