# Enumerate Primes

AC一覧

## Problem Statement問題文

Let the prime numbers be $p_0 < p_1 < p_2 < \cdots$ (i.e. $p_0 = 2$, $p_1 = 3$, $p_2 = 5$, and so on).

You are given integers $N$, $A$ and $B$. Find $\pi(N)$ (the number of primes no greater than $N$), and print $p_{Ai+B}$ for nonnegative integers $i$ with $p_{Ai+B} \le N$.

## Constraints制約

• $1 \le N \le 5 \times 10^{8}$
• $0 \le B < A \le N$
• $0 \le X \le 10^{6}$ where $X = \#\{ i \in \mathbb{Z}_{\ge 0} \mid p_{Ai+B} \le N \}$

## Input入力

$N$ $A$ $B$


## Output出力

$\pi(N)$ $X$
$p_{B}$ $p_{A+B}$ $\cdots$ $p_{A(X-1)+B}$


### # 1

100 3 1

25 8
3 11 19 31 43 59 71 83


Timelimit: 10 secs

Before submitting, please confirm terms and conditions