This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://judge.yosupo.jp/problem/enumerate_primes"
#include <bits/stdc++.h>
using namespace std;
#include "../../../lib/math/prime_sieve.hpp"
int main(){
int n, a, b; cin >> n >> a >> b;
PrimeSieve<int> s(n);
int cnt = s.getPrimeCount();
vector<int> res;
for(int i = b; i < cnt; i += a){
res.push_back(s.getKthPrime(i));
}
int cnt2 = res.size();
cout << cnt << " " << cnt2 << "\n";
for(int i = 0; i < cnt2; i++){
if(i >= 1) cout << " ";
cout << res[i];
}
cout << "\n";
}
#line 1 "test/library_checker/number_theory/enumerate_primes.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/enumerate_primes"
#include <bits/stdc++.h>
using namespace std;
#line 2 "lib/math/prime_sieve.hpp"
/**
* @brief Prime Sieve (エラトステネスの篩)
* @docs docs/math/prime-sieve.md
*/
#line 9 "lib/math/prime_sieve.hpp"
template <typename T>
struct PrimeSieve{
int n, half;
std::vector<bool> sieve;
std::vector<T> prime_list;
// sieve[i] ... 2 * i + 1
PrimeSieve(T _n) : n(_n){
init();
}
void init(){
if(n < 2){
return;
}
half = (n + 1) / 2;
sieve.assign(half, true);
sieve[0] = false;
prime_list.emplace_back(2);
for(long long i = 1; 2 * i + 1 <= n; ++i){
if(!sieve[i]) continue;
T p = 2 * i + 1;
prime_list.emplace_back(p);
for(long long j = 2 * i * (i + 1); j < half; j += p){
sieve[j] = false;
}
}
}
bool isPrime(T x){
if(x == 2) return true;
if(x % 2 == 0) return false;
return sieve[x / 2];
}
T getPrimeCount(){
return prime_list.size();
}
T getKthPrime(int k){
return prime_list[k];
}
};
#line 6 "test/library_checker/number_theory/enumerate_primes.test.cpp"
int main(){
int n, a, b; cin >> n >> a >> b;
PrimeSieve<int> s(n);
int cnt = s.getPrimeCount();
vector<int> res;
for(int i = b; i < cnt; i += a){
res.push_back(s.getKthPrime(i));
}
int cnt2 = res.size();
cout << cnt << " " << cnt2 << "\n";
for(int i = 0; i < cnt2; i++){
if(i >= 1) cout << " ";
cout << res[i];
}
cout << "\n";
}