Bulgarian OI '09 P5 - Special Sequence
View as PDF2009 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 number in this sequence.
Input Specification
The positive integer , on a single line.
Output Specification
The number in the special sequence (starting from
).
Sample Input
12
Sample Output
20102
Comments
Someday, I'll look back at this question and think to myself, "Man, publicly declaring my intention to cheat was a calculated risk, but boy am I bad at math!"