CF161E.Polycarpus the Safecracker

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarpus has tt safes. The password for each safe is a square matrix consisting of decimal digits '0' ... '9' (the sizes of passwords to the safes may vary). Alas, Polycarpus has forgotten all passwords, so now he has to restore them.

Polycarpus enjoys prime numbers, so when he chose the matrix passwords, he wrote a prime number in each row of each matrix. To his surprise, he found that all the matrices turned out to be symmetrical (that is, they remain the same after transposition). Now, years later, Polycarp was irritated to find out that he remembers only the prime numbers pip_{i} , written in the first lines of the password matrices.

For each safe find the number of matrices which can be passwords to it.

The number of digits in pip_{i} determines the number of rows and columns of the ii -th matrix. One prime number can occur in several rows of the password matrix or in several matrices. The prime numbers that are written not in the first row of the matrix may have leading zeros.

输入格式

The first line of the input contains an integer tt ( 1<=t<=301<=t<=30 ) — the number of safes. Next tt lines contain integers pip_{i} ( 10<=pi<=9999910<=p_{i}<=99999 ), pip_{i} is a prime number written in the first row of the password matrix for the ii -th safe. All pip_{i} 's are written without leading zeros.

输出格式

Print tt numbers, the ii -th of them should be the number of matrices that can be a password to the ii -th safe. Print the numbers on separate lines.

输入输出样例

  • 输入#1

    4
    11
    239
    401
    9001
    

    输出#1

    4
    28
    61
    2834
    

说明/提示

Here is a possible password matrix for the second safe:

<br></br>239<br></br>307<br></br>977<br></br>Here is a possible password matrix for the fourth safe:

<br></br>9001<br></br>0002<br></br>0002<br></br>1223 <br></br>

首页