PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000065. Liệt kê nguyên tố theo chỉ số (Enumerate Primes)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Liệt kê nguyên tố theo chỉ số (Enumerate Primes)

Enumerate Primes

Source: Library Checker

Version: Phuoc Hung OJ Extended

Problem Statement

Let p0=2,p1=3,p2=5,…p_0=2,p_1=3,p_2=5,\ldots be the increasing sequence of primes, indexed from 00. Given N,A,BN,A,B, let P=π(N)P=\pi(N) be the number of primes at most NN. Select the primes whose indices are B,A+B,2A+B,…B,A+B,2A+B,\ldots, keeping only values no greater than NN. Let XX be their count. Print P,XP,X and the chosen primes in order.

Input

One line contains three integers N,A,BN,A,B in that order.

Output

Print PP and XX on the first line. On the second line print the XX selected primes separated by spaces; print an empty second line if X=0X=0.

Subtasks

  • Subtask 1 (20 points): 1≤N≤100001\le N\le 10000; 0≤B<A≤N0\le B<A\le N; 0≤X≤1060\le X\le 10^6.
  • Subtask 2 (30 points): 1≤N≤100000001\le N\le 10000000; 0≤B<A≤N0\le B<A\le N; 0≤X≤1060\le X\le 10^6.
  • Subtask 3 (50 points): 1≤N≤5000000001\le N\le 500000000; 0≤B<A≤N0\le B<A\le N; 0≤X≤1060\le X\le 10^6.

Examples

Input

100 3 1

Output

25 8
3 11 19 31 43 59 71 83

Explanation

There are 2525 primes at most 100100. With A=3,B=1A=3,B=1, the selected zero-based indices are 1,4,7,10,13,16,19,221,4,7,10,13,16,19,22, yielding 3,11,19,31,43,59,71,833,11,19,31,43,59,71,83. Thus P=25P=25 and X=8X=8.