模拟题:

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. 【hive】分组求排名

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

  2. Powerdesigner颜色设置

    Powerdesigner颜色设置    

  3. 005——php字符串中的处理函数(四)

    <?php /** * 字符串处理函数: * parse_url 解析URL.返回其组成部分 */ /* $url="http://www.lantianwang.com/admin/ ...

  4. 面筋: 奇虎360 c++ 后台开发 实习生 面试

    投的是360上海的商业化部门,岗位是C++服务端开发实习生,记录一下面试历程: 视频面试,但是是有代码框让你写代码的. 一面: Q:先说一下个人信息,做过的项目 A:.......... Q:先写个翻 ...

  5. 今天廷鹏师弟来的java建议

    如下一段获取数据代码的问题: public Serializable getById(Serializable id) throws BaseBusinessException {  if (id = ...

  6. es6 中的generator函数控制流程

    Generator函数跟普通函数的写法有非常大的区别: 一是,function关键字与函数名之间有一个星号: 二是,函数体内部使用yield语句,定义不同的内部状态(yield在英语里的意思就是“产出 ...

  7. Django 之 分页

    1. urs.py # coding:utf-8 from django.conf.urls import url import views urlpatterns = [ # 分页练习 url(r' ...

  8. 这是C语言结课前(期末考试之前)写给牛晓霞的一封信!

    致尊敬的牛晓霞老师: 这是黄领衫的感想,也是想告诉你的话! 在老师说要给班里写得好的人发黄领衫的时候,我当时的想法是我很有可能拿到这份奖品的,怎么说呢,算是一种自信吧,或是对自己的态度的认可.虽然我能 ...

  9. sublime text2下配置c++

    今天安装了sublime text2,真是编辑神器,不再用notepad了. 笔记本上没有c++运行环境,用编辑器既轻巧,又方便,VS太臃肿了. 要在sublime text2 下运行c++程序,需要 ...

  10. UVAlive5713 Qin Shi Huang's National Road System【次小生成树】【DP】

    LINK1 LINK2 题目大意 给你平面上的n个点 每个点有一个权值 让你求出一个生成树 可以选择一条边不花费代价 要最大化这条边两边端点的权值/剩下n-2条边的长度之和 思路 发现发现其实端点权值 ...