結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー troro_kelp
提出日時 2018-06-22 18:35:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 159,100 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-06-30 18:02:54
合計ジャッジ時間 2,900 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 18 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N, L;
    
    cin >> N >> L;
    bool sieve[L+1]; 
    for(int i=0; i<L+1; ++i){
        sieve[i]=true;
    }
    sieve[0] = sieve[1] = false;
    for(int i=2; i*i<L+1; ++i){
        if(sieve[i]){
            for(int j=2; i*j<L+1; ++j){
                sieve[i*j] = false;
            }
        }
    }
    long long ans = 0;
    for(int i=0; i<L; ++i){
        if(sieve[i]&&i*(N-1) <= L){
            ans += L - i*(N-1)+1;
        }
    }
    cout << ans << endl;
    return 0;
}
0