結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー tetsuzuki1115
提出日時 2018-04-12 01:45:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 265 ms / 1,000 ms
コード長 742 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 83,572 KB
実行使用メモリ 42,592 KB
最終ジャッジ日時 2024-06-26 21:18:46
合計ジャッジ時間 3,444 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


int p[10000000] = {0};

int main() {
    long long N,L;
    cin >> N >> L;

    for ( long long i = 2; i <= L; i++ ) {
        if ( p[i] == 0 ) {
            for ( int j = i*2; j <= L; j += i ) {
                p[j] = 1;
            }
        }
    }

    long long ans = 0;
    for ( long long i = 2; i <= L; i++ ) {
        if ( p[i] == 0 && i*(N-1) <= L ) {
            ans += L-i*(N-1)+1;
        }
    }
    cout << ans << endl;

    return 0;
}
0