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
制約

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

Forum


Timelimit: 10 secs

Before submitting, please confirm terms and conditions