#P13291. [GCJ 2013 #1C] Consonants

    ID: 15156 远端评测题 3000ms 1023MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>字符串2013组合数学前缀和Google Code Jam

[GCJ 2013 #1C] Consonants

题目描述

In English, there are 2626 letters that are either vowels or consonants. In this problem, we consider a, e, i, o, and u to be vowels, and the other 2121 letters to be consonants.

A tribe living in the Greatest Colorful Jungle has a tradition of naming their members using English letters. But it is not easy to come up with a good name for a new member because it reflects the member's social status within the tribe. It is believed that the less common the name he or she is given, the more socially privileged he or she is.

The leader of the tribe is a professional linguist. He notices that hard-to-pronounce names are uncommon, and the reason is that they have too many consecutive consonants. Therefore, he announces that the social status of a member in the tribe is determined by its n-value, which is the number of substrings with at least nn consecutive consonants in the name. For example, when n=3n = 3, the name "quartz" has the n-value of 44 because the substrings quartz, uartz, artz, and rtz have at least 33 consecutive consonants each. A greater n-value means a greater social status in the tribe. Two substrings are considered different if they begin or end at a different point (even if they consist of the same letters), for instance "tsetse" contains 1111 substrings with two consecutive consonants, even though some of them (like "tsetse" and "tsetse") contain the same letters.

All members in the tribe must have their names and nn given by the leader. Although the leader is a linguist and able to ensure that the given names are meaningful, he is not good at calculating the n-values. Please help the leader determine the n-value of each name. Note that different names may have different values of nn associated with them.

输入格式

The first line of the input gives the number of test cases, TT. TT test cases follow. The first line of each test case gives the name of a member as a string of length LL, and an integer nn. Each name consists of one or more lower-case English letters.

输出格式

For each test case, output one line containing "Case #x: y", where xx is the case number (starting from 11) and yy is the n-value of the member's name.

4
quartz 3
straight 3
gcj 2
tsetse 2
Case #1: 4
Case #2: 11
Case #3: 3
Case #4: 11

提示

Limits

  • 1T1001 \leqslant T \leqslant 100.
  • 0<nL0 < n \leqslant L.

Small dataset (8 Pts, Test set 1 - Visible)

  • 1L1001 \leqslant L \leqslant 100.

Large dataset (20 Pts, Test set 2 - Hidden)

  • 1L1061 \leqslant L \leqslant 10^6.
  • The input file will be no larger than 6MB.