UVa 10785 WA谢谢
题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=19&problem=1726&mosmsg=Submission+received+with+ID+12570629
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string vowels="AAAAAAAAAAAAAAAAAAAAAUUUUUUUUUUUUUUUUUUUUUEEEEEEEEEEEEEEEEEEEEEOOOOOOOOOOOOOOOOOOOOOIIIIIIIIIIIIIIIIIIIII";
string consonants="JJJJJSSSSSBBBBBKKKKKTTTTTCCCCCLLLLLDDDDDMMMMMVVVVVNNNNNWWWWWFFFFFXXXXXGGGGGPPPPPYYYYYHHHHHQQQQQZZZZZRRRRR";
int n;
while (cin>>n)
{
for(int cas=1;cas<=n;++cas)
{
int m;
cin>>m;
string name,name1,name2;//name1存元音,name2辅音,对name1和name2排完序后再组成name
int i,j;
i=j=0;
int num=0;
int size_vowels=vowels.size();
int size_consonants=consonants.size();
while(num<m)
{
name1+=vowels[i];
i=(i+1)%size_vowels;
++num;
if(num>=m)break;
name2+=consonants[j];
j=(j+1)%size_consonants;
++num;
}
sort(name1.begin(),name1.end());
sort(name2.begin(),name2.end());
i=j=0;
while(i<name1.size()&&j<name2.size())
{
name+=name1[i++];
name+=name2[j++];
}
if(i<name1.size())
name+=name1[i];
else
name+=name2[j];
cout<<"Case "<<cas<<": "<<name<<endl;
}
}
return 0;
}