编程介的小学生 2017-12-03 05:08 采纳率: 20.5%
浏览 936
已采纳

Dice Password Security

Problem Description
NCIM Group sponsored problem.

The NCIM Group does a lot of work on IT solutions in defense and security. Good security usually starts with picking a strong password. Generating a password at random is generally a good practice. For example, a password like "2R4eZ9Rqup" is a bit harder to guess than "god", "love", "sex" or "secret".

The problem with passwords consisting of random letters and digits is that they are hard to remember. Instead of using letters and digits it is also possible to generate passwords by putting random words together. Words are easier to remember than letters and digits.

Using a dictionary of 7776 (65) words, a 5-random-word password is about as strong as a 11-random-character password.

77765 = 28430288029929701376 ≈ 3 * 1019

6211 = 52036560683837093888 ≈ 5 * 1019

Some applications hide the password you are typing on the screen by printing dots or asterisks. This allows someone watching your screen to count the number of characters in your password. The NCIM Group wants you to find out whether or not this compromises the strength of your password.

You must write a program that calculates the number of possible passwords that can be generated given:

the dictionary of words, the amount of words used to generate the password and the length of the password.

Input
On the first line an integer t (1 <= t <= 100): the number of test cases. Then for each test case:

One line with three positive integers m (1 <= m <= 7776), n (1 <= n <= 5) and q (1 <= q <= 20): the number of words in the dictionary, the number of words to generate the password, and the number of queries, respectively.

The dictionary: m lines each containing one word wi Each word consists only of lowercase letters. The length of each word will be between 3 and 10 inclusive. No word in the dictionary will be a substring of another word in the dictionary.

q lines each containing a positive integer lj (1 <= lj <= 50), the length observed.

Output
For each test case:

q lines with: the number of possible passwords with length lj . This number will be smaller than 263.

Sample Input
1
4 2 2
aap
noot
mies
piet
7
8

Sample Output
6
9

  • 写回答

1条回答 默认 最新

  • 战在春秋 2017-12-03 07:18
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 Python安装cvxpy库出问题
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题