結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー face4face4
提出日時 2018-06-03 14:45:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 1,000 ms
コード長 559 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 70,344 KB
実行使用メモリ 9,968 KB
最終ジャッジ日時 2023-09-12 21:52:11
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
9,712 KB
testcase_01 AC 43 ms
9,736 KB
testcase_02 AC 48 ms
9,968 KB
testcase_03 AC 44 ms
9,932 KB
testcase_04 AC 43 ms
9,852 KB
testcase_05 AC 44 ms
9,896 KB
testcase_06 AC 43 ms
9,720 KB
testcase_07 AC 43 ms
9,728 KB
testcase_08 AC 43 ms
9,884 KB
testcase_09 AC 44 ms
9,844 KB
testcase_10 AC 43 ms
9,808 KB
testcase_11 AC 44 ms
9,864 KB
testcase_12 AC 44 ms
9,888 KB
testcase_13 AC 43 ms
9,884 KB
testcase_14 AC 44 ms
9,844 KB
testcase_15 AC 43 ms
9,748 KB
testcase_16 AC 44 ms
9,936 KB
testcase_17 AC 44 ms
9,728 KB
testcase_18 AC 43 ms
9,784 KB
testcase_19 AC 43 ms
9,808 KB
testcase_20 AC 43 ms
9,828 KB
testcase_21 AC 44 ms
9,936 KB
testcase_22 AC 43 ms
9,712 KB
testcase_23 AC 44 ms
9,808 KB
testcase_24 AC 43 ms
9,808 KB
testcase_25 AC 43 ms
9,852 KB
testcase_26 AC 44 ms
9,804 KB
testcase_27 AC 43 ms
9,892 KB
testcase_28 AC 44 ms
9,728 KB
testcase_29 AC 43 ms
9,864 KB
testcase_30 AC 44 ms
9,720 KB
testcase_31 AC 42 ms
9,732 KB
testcase_32 AC 44 ms
9,868 KB
testcase_33 AC 44 ms
9,936 KB
testcase_34 AC 44 ms
9,744 KB
testcase_35 AC 44 ms
9,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;
#define max 5000000

bool np[max] = {};
vector<int> p;

int main(){
    np[0] = np[1] = true;
    for(int i = 2; i < max; i++){
        if(!np[i]){
            p.push_back(i);
            for(int j = i+i; j < max; j += i)   np[j] = true;
        }
    }

    ll n, l;
    cin >> n >> l;

    ll ans = 0;
    double upper = (double)l/(n-1);

    for(int prime : p){
        if(prime > upper)   break;
        ans += l-(n-1)*prime+1;
    }

    cout << ans << endl;
    return 0;
}
0