f711. 12218 - An Industrial Spy
標籤 : CPE UVA
通過比率 : 54人/61人 ( 89% ) [非即時]
評分方式:
Tolerant

最近更新 : 2021-03-25 19:22

內容

給一個數字,問用這個數字的位數能組成幾種質數

Industrial spying is very common for modern research labs. I am such an industrial spy - dont 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.

輸入說明

第一行有個數字C代表有幾筆測資(1 ≤ c ≤ 200)
接下來C行,每行有一個不超過7位數的數字

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

範例輸入 #1
4
17
1276543
9999999
011
範例輸出 #1
3
1336
0
2
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (20%): 1.0s , <1K
公開 測資點#1 (20%): 1.0s , <1K
公開 測資點#2 (20%): 1.0s , <1K
公開 測資點#3 (20%): 1.0s , <1M
公開 測資點#4 (20%): 1.0s , <1M
提示 :

2021 3月CPE第五題

標籤:
CPE UVA
出處:
UVA12218 [管理者: DE45A (一葉之秋) ]

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
24828 fire5386 (becaidorz) f711
題序補充
710 2021-03-28 17:37
24816 p3a_owhj (阿普二信) f711
解法思路
794 2021-03-28 01:30