BCH - The Longest Chain

Output the longest chain of integers which has the following properties:

  1. All integers are positive and have 4 digits in their decimal representation (i.e. all numbers are in the range [1000, 9999]).
  2. All numbers in the chain are different.
  3. The decimal representations of each number differs from the next one at only position (digit).
  4. All integers are prime.

The winner is the participant who obtains the longest chain.

Input

There is no input data in this problem.

Output

In the first line output the length of your chain N. In the next N lines output each number of your chain.

Score

The number of points you'll get for the given problem is calculated using following formula: score = 1000/(1062 - length), where length - length of your chain.

Example

Output:
3
9857
9887
9883

Score:
In this case score = 1000/(1062-3) = 0.944287,

Problem author: Filimonenkov D.O.


Added by:Roman Sol
Date:2007-09-03
Time limit:1s-30s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ZCon 2008

hide comments
2013-12-22 03:46:04 Samil Vargas
it should be partial or clasical!
2013-02-18 16:33:05 Maxim Bogoyavlenskiy
tutorial????? o_O
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.