1858. Digits Fun!

Hard运算符循环基本算法

时间限制:2000 ms

内存限制:256 MiB

题面

You enjoy working with numbers that contain only square digits (namely, 0, 1, 4 and 9). The sequence containing only these digits is 0, 1, 4, 9, 10, 11, 14... output the N-th term (indexed from 0) in this sequence.

输入格式

There are several test cases,each test case contain only a integer N(0<=N<=2^31-1).

输出格式

output the N-th term (indexed from 0) in this sequence.

样例

输入

16
123

输出

100
1949