UVa 10785 the Mad numerologist: Sort

Source: Internet
Author: User
Tags integer sort time limit

10785-the Mad numerologist

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem &problem=1726

Numerology is a science this is used by many people to find out a mans personality, sole purpose of life, desires to Exper Ience etc. Some calculations of numerology are very complex, while others are quite simple. You can sit alone in home and do this calculations without taking any ones help. However in this problem you wont is asked to find the value of your name.

To find the value of a name modern numerologists have assigned values to all the letters of 中文版 alphabet. The table on the left shows the numerical values of all letters of 中文版 alphabets. Five letters A, E, I, O, U are vowels. Rests of the letters are consonant. In this table all letters in column 1 have value 1, all letters in column 2 have value 2 and. So T has value 2, F has value 6, R has value 9, O has value 6 etc. When calculating the value of a particular name the consonants and vowels are calculated. The following picture explains this method using the name ' CHRISTOPHER RORY PAGE '.

So can I-consonant value, the values of individual consonants are added and to find the vowel value The values of individual vowels are added. A Mad Numerologist suggests people many strange lucky. He follows the rules stated below while giving lucky names.

The name has a predefined length N.

The vowel value and consonant value of the name must be kept minimum.

To make the pronunciation of the name possible vowels and consonants are placed in alternate. Actually vowels are put in odd positions and consonants put in are even. The leftmost letter of a name has position 1; The position right to it is position 2 and.

No consonants can be used into a name more than five The times and no vowels can be used in a name more than twenty-one times

Following the rules and limitations above the name must be kept lexicographically. Please note that the numerologists of the ' priority ' to keep ' vowel and consonant value minimum and then to make the NA Me lexicographically smallest.

Input

The "I" of the input file contains an integer N (0 < N250) This indicates how many sets of inputs are. Each of the next N lines contains a single set of input. The description of each set is given Below:each line contains a integer n (0 < n < 211) that indicates the Predef ined length of the name.

Output

For each set of input produce one line of output. This line contains the serial of output followed by the name of the numerologist would suggest following the rules above . All letters in the output should is uppercase 中文版 letters.

Sample Input

3
1
5
5

Sample Output

Case 1: A case
2:ajaja case
3:ajaja
Note that after you finalize the basic answer, you want to sort the parity separately.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.