模拟题:

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. oracle会自动收集统计信息-记住哦

    oracle自动收集统计信息,周一至周五  时间:22:00:00 oracle自动收集统计信息,周六.周日  时间:06:00:00

  2. Leetcode 53

    //经典class Solution { public: int maxSubArray(vector<int>& nums) { ; int maxsum = -INT_MAX; ...

  3. iOS UI-应用管理(使用Cell模板)

    一.Model // // BWApp.h // IOS_0112_应用管理 // // Created by ma c on 16/1/12. // Copyright (c) 2016年 博文科技 ...

  4. notepad++支持自定义文件类型

    场景描述: 使用notepad++编辑less.ejs文件,发现高亮和提示均无效,修改如此需要进行额外的设置: 解决方法: 以less为例, 1.设置 >语言格式设置 >语言里找到CSS, ...

  5. 006PHP文件处理—— 目录操作 删除目录 删除置顶类型文件

    <?php /** * 目录操作 删除目录 删除置顶类型文件 */ //echo rmdir('61') or die('目录删除失败'); //删除一个目录中有其他文件的内容的方法: //第1 ...

  6. delphi文件操作的总结

    csfinal90我的:收件箱资源博客空间设置|帮助|退出 首页 业界 移动 云计算 研发 论坛 博客 下载 更多 windzb的专栏 目录视图 摘要视图 订阅 IT俱乐部创始人杜鸿飞专访       ...

  7. android adapter的性能小结

    一般adapter的做法会重写getView方法 比如 @Override public View getView(int position, View convertView, ViewGroup ...

  8. 『转』Emsisoft Anti-Malware 8刷Key教程 - 文字版

    先分主机和客机,下载好 EAM8安装包 和 30天重置工具EAM Trial Reset 1.1.exe 1. 主机安装 Emsisoft Anti-Malware 8 并激活30天试用版   如果已 ...

  9. Nginx 反向代理 如何在web应用中获取用户ip

    转载:http://blog.csdn.net/bao19901210/article/details/52537279 问题背景: 在实际应用中,我们可能需要获取用户的ip地址,比如做异地登陆的判断 ...

  10. Jmeter二次开发之代码环境搭建(QQ交流群:577439379)

    一.创建项目 1. 分别下载apache3.1 binaries和source两个压缩包,前者为release版本,后者为jmeter最新的源码,下载地址:http://jmeter.apache.o ...