2772. An Industrial Spy

单点时限: 5.0 sec

内存限制: 256 MB

Industrial spying is very common for modern research labs. I am such an industrial spy { don’t tell anybody! My recent job was to steal the latest inventions from a famous math research lab. It was hard to obtain some of their results but I got their waste out of a document shredder.

I have already reconstructed that their research topic is fast factorization. But the remaining paper snippets only have single digits on it and I cannot imagine what they are for. Could it be that those digits form prime numbers? Please help me to nd out how many prime numbers can be formed using the given digits.

输入格式

The first line of the input holds the number of test cases c (1 <= c <= 200). Each test case consists of a single line. This line contains the digits (at least one, at most seven) that are on the paper snippets.

输出格式

For each test case, print one line containing the number of different primes that can be reconstructed by shuffling the digits. You may ignore digits while reconstructing the primes (e.g., if you get the digits 7 and 1, you can reconstruct three primes 7, 17, and 71). Reconstructed numbers that (regarded as strings) differ just by leading zeros, are considered identical (see the fourth case of the sample input).

样例

Input
4
17
1276543
9999999
011
Output
3
1336
0
2

11 人解决,21 人已尝试。

18 份提交通过,共有 51 份提交。

6.4 EMB 奖励。

创建: 15 年,1 月前.

修改: 7 年,3 月前.

最后提交: 1 年,1 月前.

来源: NWERC 2009

题目标签