結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー dnkdnk
提出日時 2016-08-05 22:56:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 71 ms / 1,000 ms
コード長 533 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 143,236 KB
実行使用メモリ 13,400 KB
最終ジャッジ日時 2023-08-22 04:02:06
合計ジャッジ時間 5,568 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
13,364 KB
testcase_01 AC 63 ms
13,252 KB
testcase_02 AC 62 ms
13,116 KB
testcase_03 AC 63 ms
13,204 KB
testcase_04 AC 63 ms
13,260 KB
testcase_05 AC 62 ms
13,264 KB
testcase_06 AC 63 ms
13,120 KB
testcase_07 AC 62 ms
13,180 KB
testcase_08 AC 63 ms
13,156 KB
testcase_09 AC 62 ms
13,172 KB
testcase_10 AC 63 ms
13,260 KB
testcase_11 AC 62 ms
13,400 KB
testcase_12 AC 62 ms
13,148 KB
testcase_13 AC 63 ms
13,396 KB
testcase_14 AC 62 ms
13,116 KB
testcase_15 AC 62 ms
13,264 KB
testcase_16 AC 62 ms
13,096 KB
testcase_17 AC 63 ms
13,140 KB
testcase_18 AC 62 ms
13,124 KB
testcase_19 AC 63 ms
13,096 KB
testcase_20 AC 66 ms
13,116 KB
testcase_21 AC 63 ms
13,120 KB
testcase_22 AC 63 ms
13,124 KB
testcase_23 AC 62 ms
13,120 KB
testcase_24 AC 62 ms
13,140 KB
testcase_25 AC 67 ms
13,252 KB
testcase_26 AC 62 ms
13,100 KB
testcase_27 AC 62 ms
13,156 KB
testcase_28 AC 61 ms
13,252 KB
testcase_29 AC 64 ms
13,092 KB
testcase_30 AC 62 ms
13,204 KB
testcase_31 AC 63 ms
13,200 KB
testcase_32 AC 65 ms
13,112 KB
testcase_33 AC 70 ms
13,180 KB
testcase_34 AC 71 ms
13,088 KB
testcase_35 AC 67 ms
13,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int N = 1e7;
bool isPrime[N + 1];

int main() {
    for (int i = 2; i <= N; ++i) isPrime[i] = true;
    for (int i = 2; i * i <= N; ++i) if (isPrime[i]) {
        for (int j = i * i; j <= N; j += i) if (isPrime[j]) {
            isPrime[j] = false;
        }
    }
    int n; cin >> n;
    int l; cin >> l;
    long long res = 0;
    for (int d = 1; 1LL * (n - 1) * d <= l; ++d) if (isPrime[d]) {
        res += l - (n - 1) * d + 1;
    }
    cout << res << '\n';
    return 0;
}
0