## Bulgarian OI '09 P5 - Special Sequence

View as PDF

Points: 30 (partial)
Time limit: 0.6s
Memory limit: 32M

Problem type
##### 2009 Bulgarian Olympiad in Informatics

Consider the positive integers whose squares contain only (and all) the digits . Let's call them "special". For example, is special, because and the square contains only (and all) of . is also special: . and are not special - ( and aren't allowed) and (there's no )

Consider the sequence of special numbers, in order:
Write a program to find the th number in this sequence.

#### Input Specification

The positive integer , on a single line.

#### Output Specification

The th number in the special sequence (starting from ).

#### Sample Input

12

#### Sample Output

20102