402799: GYM100883 J palprime
Memory Limit:24 MB
Time Limit:4 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
J. palprimetime limit per test4 secondsmemory limit per test24 megabytesinputstandard inputoutputstandard output
A palindromic prime (sometimes called a palprime) is a prime number that is also a palindromic number. Palindromicity depends on the base of the numbering system and its writing conventions, while primality is independent of such concerns.
The sequence of binary palindromic primes begins(in binary):
11, 101, 111, 10001, 11111, 1001001 You are given a number b (in binary), you should output the first palprime greater than or equal to b.
InputThe input consists of multiple test cases, each test case consists of a number b in binary.
We guarantee b will be no Longer than 21 bits
OutputThe first palprime greater than or equal to b
ExamplesInput10Output
100
110
1000
11
101
111
10001