REMEMBER THE NUMBERS
All submissions for this problem are available.
Our little chef is little dumb. So much dumb that when his crush gave him her number he forgets it. But since little dumbo chef is such a good friend of yours you decided to help him. Here is some vague memories of the number that chef can recall :
1.It is a palindrome.
2.It is a prime number.
3.It is of n digits ( 4 < n < 11 ).
After digesting a memory enhancement pill he recalls (n-2) digits of the number. Now since the search criteria is so much narrowed, you are to write a program which prints number of possible candidates of the phone number of his crush.
A number is a successful candidate if :
1. It is prime and a palindrome.
2. It is of n digits.
3. Only deletion of two digits from the potential candidate makes it equal to the number which the chef has recalled.
The first line of the input contains an integer T denoting the number of test cases, for each test case enter the number sequence recalled by chef of N - 2 digits and digits of original number i.e N
For each test case, output a single line with number of phone numbers possible.
- 4 ≤ N ≤ 11
Input: 2 37343 7 57675 7 Output: 1 1
Case 1 : 1 number is possible i.e 3743473
Case 2 : 1 number is possible i.e. 7576757
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.