0228. Prime Sum

Имя входного файла: prime.in
Имя выходного файла: prime.out
Ограничение по времени: 750 ms
Ограничение по памяти: 64 megabytes

Find all pairs of prime numbers (A, B) such that A < B and their sum is also a prime number and does not exceed N.

Input file

The input of the problem consists of the only integer N (1 ≤ N ≤ 106).

Output file

On the first line of the output file write the number of pairs meeting the requirements. Then output all pairs one per line (two primes separated by a space).

Example:

prime.inprime.out
4 0


Источник: Petrozavodsk Winter 2004. SPb ETU Contest, Sunday, February 01

Обсудить       Отправить решение



Версия для печати