Time Limit: Java: 2000 ms / Others: 2000 ms

Memory Limit: Java: 65536 KB / Others: 65536 KB

Recently, DD found that 9875321 was a very special number, and it has three properties:

(1) 9875321 is a prime number.

(2) reverse it, we get 1235789, which is also a prime number.

(3) the digits of 9875321 are in strictly descreasing order.

Above all, for all the decimal numbers with the three properties, 9875321 is the maximal one. So we say 9875321 is very special.

Now, given N (2<=N<=16), find the N-based very special number. For N>10, we use capitals 'A', 'B', 'C'...

(1) 9875321 is a prime number.

(2) reverse it, we get 1235789, which is also a prime number.

(3) the digits of 9875321 are in strictly descreasing order.

Above all, for all the decimal numbers with the three properties, 9875321 is the maximal one. So we say 9875321 is very special.

Now, given N (2<=N<=16), find the N-based very special number. For N>10, we use capitals 'A', 'B', 'C'...

提交代码