博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA10785 The Mad Numerologist
阅读量:4308 次
发布时间:2019-06-06

本文共 3700 字,大约阅读时间需要 12 分钟。

虽然是sorting的压轴,但是比起前面真心水题。这个专题结合前面string的很多,排序相对简单了,qsort基本解决。

题目:

 

  The Mad Numerologist 

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.

\epsfbox{p10785a.eps}

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

\epsfbox{p10785b.eps}

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 < N$ \le$250) 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 

3155

Sample Output 

Case 1: ACase 2: AJAJACase 3: AJAJA

 


Miguel Revilla 2004-12-02

题目:

 

1 #include
2 #include
3 #include
4 char con[10][5],vow[10],n0[150],n1[150]; 5 int cmp_char(const void *a,const void *b) 6 { 7 return *(char*)a-*(char*)b; 8 } 9 void doit()10 {11 sprintf(con[0],"%s","JS");12 sprintf(con[1],"%s","BKT");13 sprintf(con[2],"%s","CL");14 sprintf(con[3],"%s","DMV");15 sprintf(con[4],"%s","NW");16 sprintf(con[5],"%s","FX");17 sprintf(con[6],"%s","GPY");18 sprintf(con[7],"%s","HQZ");19 sprintf(con[8],"%s","R");20 vow[0]='A';21 vow[1]='U';22 vow[2]='E';23 vow[3]='O';24 vow[4]='I';25 }26 int main()27 {28 doit();29 int n,now=0,cn,vn;30 scanf("%d",&n);31 while(n--)32 {33 cn=5,vn=21;34 int t,i,cp=0,vp=0,p0=0,p1=0,jj=0;35 scanf("%d",&t);36 for(i=0;i

 

 

 

转载于:https://www.cnblogs.com/terryX/archive/2013/02/20/2918945.html

你可能感兴趣的文章
HIVE—索引、分区和分桶的区别
查看>>
Hive进阶总结(听课总结)
查看>>
大数据领域两大最主流集群管理工具Ambari和Cloudera Manger
查看>>
Sqoop往Hive导入数据实战
查看>>
Mysql到HBase的迁移
查看>>
Sqoop import进阶
查看>>
Hive语句是如何转化成MapReduce任务的
查看>>
Hive创建table报错:Permission denied: user=lenovo, access=WRITE, inode="":suh:supergroup:rwxr-xr-x
查看>>
Hive执行job时return code 2排查
查看>>
hive常用函数及数据结构介绍
查看>>
Hive面试题干货(亲自跟着做了好几遍,会了的话对面试大有好处)
查看>>
力扣题解-230. 二叉搜索树中第K小的元素(递归方法,中序遍历解决)
查看>>
力扣题解-123. 买卖股票的最佳时机 III(动态规划)
查看>>
Django 源码阅读:服务启动(wsgi)
查看>>
Django 源码阅读:url解析
查看>>
Docker面试题(一)
查看>>
第一轮面试题
查看>>
2020-11-18
查看>>
Docker面试题(二)
查看>>
一、redis面试题及答案
查看>>