ContinueLib

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Continue765/ContinueLib

:heavy_check_mark: test/library_checker/number_theory_enumerate_primes.test.cpp

Depends on

Code

#define PROBLEM "https://judge.yosupo.jp/problem/enumerate_primes"
#include <common.hpp>
#include "number_theory/sieve.hpp"

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    sieve(n);
    vector<int> selected;
    for (int i = b; i < static_cast<int>(primes.size()); i += a) selected.push_back(primes[i]);
    cout << primes.size() << ' ' << selected.size() << '\n';
    for (int i = 0; i < static_cast<int>(selected.size()); i++) cout << (i ? " " : "") << selected[i];
    cout << '\n';
}
Back to top page