結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー imulanimulan
提出日時 2016-08-08 02:39:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 1,000 ms
コード長 737 bytes
コンパイル時間 1,324 ms
コンパイル使用メモリ 167,544 KB
実行使用メモリ 18,980 KB
最終ジャッジ日時 2023-08-22 04:54:06
合計ジャッジ時間 6,075 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
18,252 KB
testcase_01 AC 92 ms
18,352 KB
testcase_02 AC 94 ms
17,172 KB
testcase_03 AC 96 ms
17,752 KB
testcase_04 AC 93 ms
16,920 KB
testcase_05 AC 95 ms
17,320 KB
testcase_06 AC 95 ms
17,808 KB
testcase_07 AC 101 ms
17,176 KB
testcase_08 AC 98 ms
18,000 KB
testcase_09 AC 91 ms
17,512 KB
testcase_10 AC 92 ms
17,672 KB
testcase_11 AC 92 ms
17,108 KB
testcase_12 AC 96 ms
18,300 KB
testcase_13 AC 94 ms
17,148 KB
testcase_14 AC 95 ms
16,872 KB
testcase_15 AC 100 ms
18,980 KB
testcase_16 AC 100 ms
17,640 KB
testcase_17 AC 104 ms
17,964 KB
testcase_18 AC 95 ms
17,180 KB
testcase_19 AC 98 ms
17,184 KB
testcase_20 AC 100 ms
17,460 KB
testcase_21 AC 98 ms
18,136 KB
testcase_22 AC 93 ms
17,052 KB
testcase_23 AC 93 ms
17,132 KB
testcase_24 AC 93 ms
17,012 KB
testcase_25 AC 93 ms
17,316 KB
testcase_26 AC 97 ms
17,708 KB
testcase_27 AC 96 ms
17,404 KB
testcase_28 AC 94 ms
17,136 KB
testcase_29 AC 96 ms
17,380 KB
testcase_30 AC 97 ms
17,712 KB
testcase_31 AC 96 ms
18,452 KB
testcase_32 AC 99 ms
17,772 KB
testcase_33 AC 97 ms
17,872 KB
testcase_34 AC 95 ms
16,876 KB
testcase_35 AC 94 ms
17,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N=10000000;

bool prime[N+1];

int main()
{
    fill(prime,prime+N+1,true);
    prime[0]=prime[1]=false;
    for(int i=2; i<=N; ++i)
    {
        if(prime[i]) for(int j=2; i*j<=N; ++j) prime[i*j]=false;
    }

    vector<int> p;
    rep(i,N+1) if(prime[i]) p.pb(i);

    int n,L;
    cin >>n >>L;

    ll ans=0;
    for(int i=0; (n-1)*p[i]<=L; ++i) ans+=L-(n-1)*p[i]+1;
    cout << ans << endl;
    return 0;
}
0