22818_AnIndustrialSpy

2022-5-16 18:23| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506985428900-Problem List-采集的数据-后羿采集器.html

Pro.ID

22818

Title

An Industrial Spy

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22818

AC

7

Submit

23

Ratio

30.43%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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 find 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.

    输出

    Description

    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 find out how many prime numbers can be formed using the given digits.

    Input

    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.

    Output

    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).

    Sample Input

    4
    17
    1276543
    9999999
    011

    Sample Output

    3
    1336
    0
    2

    Source

    样例输入

    4
    17
    1276543
    9999999
    011

    样例输出

    3
    1336
    0
    2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部