日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UVA10785 The Mad Numerologist

發布時間:2023/12/10 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UVA10785 The Mad Numerologist 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

雖然是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.

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

?


Miguel Revilla 2004-12-02

題目:

?

1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 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<t;i++) 37 { 38 if((i+1)%2==0) 39 { 40 n0[p0]=con[cp][jj]; 41 p0++; 42 cn--; 43 if(cn==0) 44 { 45 cn=5; 46 jj++; 47 if(con[cp][jj]=='\0') 48 { 49 cp++; 50 jj=0; 51 } 52 } 53 } 54 else 55 { 56 n1[p1]=vow[vp]; 57 p1++; 58 vn--; 59 if(vn==0) 60 { 61 vn=21; 62 vp++; 63 } 64 } 65 } 66 n1[p1]='\0'; 67 n0[p0]='\0'; 68 qsort(n1,p1,sizeof(char),cmp_char); 69 qsort(n0,p0,sizeof(char),cmp_char); 70 printf("Case %d: ",++now); 71 p1=0; 72 p0=0; 73 for(i=0;i<t;i++) 74 { 75 if((i+1)%2==0) 76 { 77 printf("%c",n0[p0]); 78 p0++; 79 } 80 else 81 { 82 printf("%c",n1[p1]); 83 p1++; 84 } 85 } 86 printf("\n"); 87 } 88 return 0; 89 }

?

?

?

轉載于:https://www.cnblogs.com/terryX/archive/2013/02/20/2918945.html

總結

以上是生活随笔為你收集整理的UVA10785 The Mad Numerologist的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。