UVa 10785 The Mad Numerologist:排序

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 that is used by many people to find out a mans personality, sole purpose of life, desires to experience etc. Some calculations of numerology are very complex, while others are quite simple. You can sit alone at home and do these easy calculations without taking any ones help. However in this problem you wont be 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 English Alphabet. The table on the left shows the numerical values of all letters of English 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 on. 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 separately. The following picture explains this method using the name ``CHRISTOPHER RORY PAGE".

So you can see that to find the 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 names. 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 positions. Actually vowels are put in odd positions and consonants are put in even positions. The leftmost letter of a name has position 1; the position right to it is position 2 and so on.

No consonants can be used in a name more than five 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 smallest. Please note that the numerologists first priority is to keep the vowel and consonant value minimum and then to make the name lexicographically smallest.

Input

First line of the input file contains an integer N ( 0 < N250) that indicates how many sets of inputs are there. Each of the next N lines contains a single set of input. The description of each set is given below: Each line contains an integer n ( 0 < n < 211) that indicates the predefined 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 that the numerologist would suggest following the rules above. All letters in the output should be uppercase English letters.

Sample Input

3
1
5
5

Sample Output

Case 1: A
Case 2: AJAJA
Case 3: AJAJA
注意最后确定基本答案后要奇偶分别排序。

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索name
, value
, and
, of
The
realm of the mad god、the mad hatcher、realmofthemadgod、the mad bomber、the mad hatter,以便于您获取更多的相关知识。

时间: 2024-09-20 10:45:42

UVa 10785 The Mad Numerologist:排序的相关文章

UVa 755 / POJ 1002 487--3279 (排序)

755 - 487--3279 Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=696 http://poj.org/problem?id=1002 Businesses like to have memorable telephone numbers. On

UVa 10305 Ordering Tasks:拓扑排序模板

10305 - Ordering Tasks Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1246 模板题.注意倒着输出. 模板: 01./*0.022s*/ 02. 03.#include<bits/stdc++.h> 04.using na

UVa 10305:Ordering Tasks , 经典的拓扑排序

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=105&page=show_problem&problem=1246 题目类型: 拓扑排序 题目: John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is onl

UVa 200 Rare Order:拓扑排序

200 - Rare Order Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=136 题意:给一列单词,这些单词是按一种未知的字典顺序排列的,要求输出这些字母的顺序. 思路:很明显,拓扑排序. 注意最后要多输出一个换行,否则会WA! 完整代码: /*0.0

UVa 642 Word Amalgamation:查字典&amp;amp;字符串排序

642 - Word Amalgamation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=583 In millions of newspapers across the United States there is a word game called Jumble. The object of this game

UVa 400 Unix ls:字符串排序&amp;amp;规格化输出

400 - Unix ls Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=341 The computer company you work for is introducing a brand new computer line and is develo

UVA之11462 - Age Sort

[题目] You are given the ages (in years) of all people of a country with at least 1 year of age. You know that no individual in that country lives for 100 or more years. Now, you are given a very simple task of sorting all the ages in ascending order.

UVa 10905 Children&#039;s Game 解法

题目:给出一组数,把这些数连接起来形成一个大数. 出处:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1846 数据很大,使用long long都会溢出,所以要使用字符代表数值. 一个知识点: 注意比较排序的比较函数 - 就是这里卡了一下,不能是按字典顺序排序,而是要有特殊写法, 如下cmp函数. bool cmp(const string

UVa 10905:Children&#039;s Game

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1846 类型: 排序 There are lots of number games for children. These games are pretty easy to play but not so easy to make. We will