結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー tactac
提出日時 2019-08-02 10:33:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 633 ms / 1,000 ms
コード長 1,150 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 166,104 KB
実行使用メモリ 31,788 KB
最終ジャッジ日時 2023-09-18 18:09:56
合計ジャッジ時間 25,543 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 563 ms
31,628 KB
testcase_01 AC 572 ms
31,496 KB
testcase_02 AC 565 ms
31,492 KB
testcase_03 AC 595 ms
31,632 KB
testcase_04 AC 600 ms
31,632 KB
testcase_05 AC 577 ms
31,604 KB
testcase_06 AC 597 ms
31,736 KB
testcase_07 AC 599 ms
31,540 KB
testcase_08 AC 610 ms
31,512 KB
testcase_09 AC 612 ms
31,540 KB
testcase_10 AC 608 ms
31,496 KB
testcase_11 AC 614 ms
31,676 KB
testcase_12 AC 618 ms
31,720 KB
testcase_13 AC 606 ms
31,688 KB
testcase_14 AC 606 ms
31,724 KB
testcase_15 AC 626 ms
31,684 KB
testcase_16 AC 626 ms
31,676 KB
testcase_17 AC 625 ms
31,684 KB
testcase_18 AC 608 ms
31,616 KB
testcase_19 AC 602 ms
31,736 KB
testcase_20 AC 633 ms
31,632 KB
testcase_21 AC 578 ms
31,660 KB
testcase_22 AC 555 ms
31,736 KB
testcase_23 AC 601 ms
31,516 KB
testcase_24 AC 603 ms
31,736 KB
testcase_25 AC 594 ms
31,748 KB
testcase_26 AC 569 ms
31,536 KB
testcase_27 AC 574 ms
31,676 KB
testcase_28 AC 567 ms
31,740 KB
testcase_29 AC 566 ms
31,600 KB
testcase_30 AC 564 ms
31,788 KB
testcase_31 AC 593 ms
31,616 KB
testcase_32 AC 591 ms
31,492 KB
testcase_33 AC 595 ms
31,732 KB
testcase_34 AC 599 ms
31,492 KB
testcase_35 AC 592 ms
31,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)

vector<int> sieve() {
    const int MAX_N = 7369791 + 1;
    vector<int> v(MAX_N, 0);
    v[0] = v[1] = 1;
    for (int i = 2; i * i <= MAX_N; ++i) {
        int tmp = 2;
        while (tmp * i <= MAX_N) {
            v[tmp++ * i] = 1;
        }
    }
    return v;
}

int main() {
    auto v = sieve();
    int n, l;
    cin >> n >> l;
    ll sum = 0;
    rep(i, SZ(v)) {
        if (v[i] == 1) continue;
        ll tmp = l - (n - 1) * i;
        tmp += 1;
        // out(v[i] << " " << tmp);
        if (tmp <= 0) break;
        sum += tmp;
    }
    out(sum);
}
0