模拟题:

1• The name has a predefined length N.名字长度N
2• The vowel value and consonant value of the name must be kept minimum.元音部分值的总和和辅音部分值的最小
3• 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.元音在奇数位置,辅音在偶数位置,第一个字母位置是1
4• 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 同一个元音字母最多可以用21次,辅音5次
5• 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.字母序最小

还要五个题就可以做下一章节了

#include <iostream>
#include<memory.h>
#include<stdio.h>
using namespace std; char vowel[] = { 'A', 'U', 'E', 'O', 'I' };
char c[] = { 'J', 'S', 'B', 'K', 'T', 'C', 'L', 'D', 'M', 'V', 'N', 'W', 'F',
'X', 'G', 'P', 'Y', 'H', 'Q', 'Z', 'R' }; void sort(int l, char cc[])
{
for (int i = ; i < l; i++)
{
for (int j = ; j < l-i; j++)
{
if (cc[j - ] > cc[j])
{
char c = cc[j - ];
cc[j - ] = cc[j];
cc[j] = c;
}
}
} } int main()
{
freopen("d:\\1.txt", "r", stdin);
int n;
cin >> n;
int used[];
int t = ;
while (n--)
{
memset(used, , sizeof(used));
//N位
//value最小
//元音奇数位,常量偶数位
//元音最大不超过21,常量5
//字典序最小
string str = "";
int m;
cin >> m;
int vi = , ci = ;
char vv[];
char cc[];
int vl = ;
int cl = ;
for (int i = ; i <= m; i++)
{
if (i % )
{
//奇数位,元音
if (used[vowel[vi]] == )
{
vi++;
}
vv[vl++] = vowel[vi];
used[vowel[vi]]++;
}
else
{
if (used[c[ci]] == )
{
ci++;
}
cc[cl++] = c[ci];
used[c[ci]]++;
}
} sort( vl, vv);
sort(cl,cc);
vi = ;
ci = ;
for(int i = ;i <=m;i++){
if(i%)
str = str + vv[vi++];
else
str = str + cc[ci++];
}
cout << "Case " << t << ": " << str << endl;
t++;
}
return ;
}

uva-10785-模拟水题的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. UVa 489 HangmanJudge --- 水题

    UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜 ...

  3. UVa 1585 Score --- 水题

    题目大意:给出一个由O和X组成的串(长度为1-80),统计得分. 每个O的分数为目前连续出现的O的个数,例如,OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3 解题思路:用一个变量t ...

  4. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  5. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

  6. UVA - 442 Matrix Chain Multiplication(栈模拟水题+专治自闭)

    题目: 给出一串表示矩阵相乘的字符串,问这字符串中的矩阵相乘中所有元素相乘的次数. 思路: 遍历字符串遇到字母将其表示的矩阵压入栈中,遇到‘)’就将栈中的两个矩阵弹出来,然后计算这两个矩阵的元素相乘的 ...

  7. 模拟水题,查看二维数组是否有一列都为1(POJ2864)

    题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...

  8. UVA 11636-Hello World!(水题,猜结论)

    UVA11636-Hello World! Time limit: 1.000 seconds When you first made the computer to print the sentenc ...

  9. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  10. HDU4287-STL模拟水题

    一场2012天津网络预选赛的题,签到题. 但是还是写了三四十分钟,C++和STL太不熟悉了,总是编译错误不知道怎么解决. 一开始用的Char [] 后来改成了string,STL和string搭配起来 ...

随机推荐

  1. Android之网络图片加载的5种基本方式

    学了这么久,最近有空把自己用到过的网络加载图片的方式总结了出来,与大家共享,希望对你们有帮助. 此博客包含Android 5种基本的加载网络图片方式,包括普通加载HttpURLConnection.H ...

  2. 【hive】分组求排名

    分组求排名 相信好多使用Mysql的用户一定对分组求排名的需求感到发怵. 但是在hive或者oracle来说就能简单实现. 采用窗口函数:rank() over() / row_number() ov ...

  3. Git创建仓库的方法(github翻译)

    …通过命令行创建一个新的仓库 echo "# GitTest" >> README.md # 船舰一个说明文件,说明内容是 "# GitTest" ...

  4. CSS3全新的背景图片方案

    CSS3全新的背景图片方案 firefox支持指定一个元素的ID将它作为另一个元素的背景-moz-element(#ID), webkit系支持-webkit-canvas(xxxx)动态创建一个ca ...

  5. Cobbler自动化安装

    # Cobbler自动化安装 [Cobbler官网](http://cobbler.github.io) ![](/Users/wanyongzhen/Library/Containers/com.t ...

  6. Window 7 平台的IE11浏览器预览版发布

    继之前Windows 8.1 带来了IE11浏览器之后,今天Window 7 以及Windows Server 2008 R2平台的IE11浏览器预览版也已经发布. 当然这还只是一个开发者预览版,可能 ...

  7. 【转】Selenium2 API详解

    [转自]http://blog.csdn.net/wuxuehong0306/article/details/49762961 打开浏览器 Ø  打开firefox浏览器 WebDriver driv ...

  8. Django 之 富文本编辑器-tinymce

    这里的富文本编辑器以 tinymce 为例. 环境:ubuntu 16.04 + django 1.10 + python 2.7 ubuntu安装tinymce: python 2.7 $ sudo ...

  9. 送人玫瑰,手留余香——2015年技术分享交流小结

    飞测说:分享让我们更加团结,交流让我们更加凝聚,送人玫瑰,手留余香,更多分享交流也让自己成长的更加完善,2015年已经过去了好几个月,今天刚好整理了下我们科大讯飞武汉测试团队技术分享交流的这块,顺便做 ...

  10. 宏使用 Tricks

    人为地定义一些"无意义"的宏(宏名本身有意义),以起到提升代码程序的可读性. 1. IN/OUT 指定参数用于输入还是输出: #define IN #define OUT void ...