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}](http://www.bnuoj.com/bnuoj/external/107/p10785a.jpg)
![\epsfbox{p10785b.eps}](http://www.bnuoj.com/bnuoj/external/107/p10785b.jpg)
- 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$](http://www.bnuoj.com/bnuoj/external/107/10785img3.png)
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
吐槽一下,最近UVa OJ可能是服务器在维修,一直没用。终于被我从其他OJ上面找到了对应的题目。。哈哈哈哈
这道题确实很难懂。。。英语不行,无力吐槽。。
其实就是按照给定规则输出单词。不翻译了
wa了一次,因为没有看到最后输出的时候还要再按照字典顺序。
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; char name[220]={"AJAJAJAJAJASASASASASABABABABABAKAKAKAKAKATUTUTUTUTUCUCUCUCUCULULULULULUDUDUDUDUDUMUMEMEMEMEVEVEVEVEVENENENENENEWEWEWEWEWEFEFEFOFOFOXOXOXOXOXOGOGOGOGOGOPOPOPOPOPOYOYOYOYIYIHIHIHIHIHIQIQIQIQIQIZIZIZIZIZIRIRIRIRIR"}; char odd[220]; char even[220]; int main () { int t,n,i=1,j; cin>>t; while(t--) { int p,k; p=0; k=0; memset(odd,0,sizeof(odd)); memset(even,0,sizeof(even)); scanf("%d",&n); printf("Case %d: ",i); for (j=0; j<n; j+=2) even[p++]=name[j]; for (j=1; j<n; j+=2) odd[k++]=name[j]; sort(even,even+p); sort(odd,odd+k); int z=0,pp=0,kk=0; for (pp=0,kk=0; kk<k || pp<p; pp++,kk++) { if (pp!=p) printf("%c",even[pp]); if (kk!=k) printf("%c",odd[kk]); } cout<<endl; i++; } return 0; }