Raju and his safes
All submissions for this problem are available.
Raju bought some books from the market and kept them into his group of safes in his room.Tomorrow is his exam and he wants to take out some books from the safes.but his mother who know the passwords of all the safes is not at home and she will come late at night.
Raju has two options left either he should wait for his mother to come home or try to open a group of safes by using his conventional tools, drilling and fiber camera.However, these safes come under a special category where he can’t open a safe without triggering the anti-theft alarm. The only way he can gain access to these safes is by knowing their passwords.He know that if he would select the first option then he will definitely fail in tomorrow,s exam.So There is nothing he can do other than waiting for his mother.
Suddenly Raju remembered what his mother taught him about these safes. he remembered that the password to each safe is in the form of a square matrix containing digits from 0 to 9. Each row of the matrix has a prime number. Also, the password matrix is symmetric in nature i.e. Transpose( A)=A.
Now the problem is that Raju only remembers the prime numbers ni in the first line of each safe’s password but he knows that total digits of ni determines the dimension of password matrix for safe i.
Can you help him in finding the total password combinations for each safe???
Each prime number can occur in one than one rows of password matrix or in several matrices. The prime numbers which are not first line prime numbers can start with zeros.
The first line of the input contains an integer t — the number of safes. Next t lines contain integers n, niis a prime number written in the first row of the password matrix for the i-th safe. All ni'sdo not have leading zeros.
Print t numbers, the i-th of them should be the number of matrices that can be a password to the i-th safe. Print the numbers on separate lines.
- 1 ≤ t ≤ 30
- 1 ≤ ni ≤ 99999
Input: 4 11 239 401 9001 Output: 4 28 61 2834
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, 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, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.