uva-10785-模拟水题
模拟题:
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-模拟水题的更多相关文章
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- UVa 489 HangmanJudge --- 水题
UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜 ...
- UVa 1585 Score --- 水题
题目大意:给出一个由O和X组成的串(长度为1-80),统计得分. 每个O的分数为目前连续出现的O的个数,例如,OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3 解题思路:用一个变量t ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- UVA 10714 Ants 蚂蚁 贪心+模拟 水题
题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...
- UVA - 442 Matrix Chain Multiplication(栈模拟水题+专治自闭)
题目: 给出一串表示矩阵相乘的字符串,问这字符串中的矩阵相乘中所有元素相乘的次数. 思路: 遍历字符串遇到字母将其表示的矩阵压入栈中,遇到‘)’就将栈中的两个矩阵弹出来,然后计算这两个矩阵的元素相乘的 ...
- 模拟水题,查看二维数组是否有一列都为1(POJ2864)
题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...
- UVA 11636-Hello World!(水题,猜结论)
UVA11636-Hello World! Time limit: 1.000 seconds When you first made the computer to print the sentenc ...
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
- HDU4287-STL模拟水题
一场2012天津网络预选赛的题,签到题. 但是还是写了三四十分钟,C++和STL太不熟悉了,总是编译错误不知道怎么解决. 一开始用的Char [] 后来改成了string,STL和string搭配起来 ...
随机推荐
- Kolakoski数列
2018-04-16 15:40:16 Kolakoski序列是一个仅由1和2组成的无限数列,是一种通过“自描述”来定义的数列.他在整数数列大全网站上排名第二位,足见该数列在组合数学界中的重要性. K ...
- uva10689矩阵快速幂
#include<map> #include<set> #include<cmath> #include<queue> #include<stac ...
- idea中解决Git反复输入代码的问题
打开git终端,或者idea中的插件终端,输入命令: git config --global credential.helper store 借用一下别人的图不要介意哈.......... 执行上述命 ...
- TVD$XTAT在linux下安装使用详解
扩展跟踪文件分析工具 (TVD$XTAT)是个命令行工具.和TKPROF一样,主要目的是把原始跟踪文件作为输入内容生成一个格式化的文件作为输出内容.输出文件可以是HTML或是文本文件.界面非常友好,推 ...
- windows下mysql多实例安装
在学习和开发过程中有时候会用到多个MySQL数据库,比如Master-Slave集群.分库分表,开发阶段在一台机器上安装多个MySQL实例就显得方便不少. 在 MySQL教程-基础篇-1.1-Wind ...
- Android 遍历全国的地区二(获取天气)
根据上次的内容 1. 界面布局 weather_layout.xml <LinearLayout xmlns:android="http://schemas.android.com/a ...
- 多线程--Thread.join方法
在Thread类的Api中,Join的作用是让当前线程等待目标线程结束之后才继续执行. thread.Join把指定的线程加入到当前线程,可以将两个交替执行的线程合并为顺序执行的线程. 比如在线程B ...
- gulp-css-spriter 将css代码中的切片图片合并成雪碧图
NPM地址:https://www.npmjs.com/package/gulp-css-spriter/ 配置gulpfile.js: var gulp = require('gulp'), ...
- redux-thunk中间件源码
浅析redux-thunk中间件源码 大多redux的初学者都会使用redux-thunk中间件来处理异步请求,其理解简单使用方便(具体使用可参考官方文档).我自己其实也一直在用,最近偶然发现其源码只 ...
- Winform工具栏ToolStrip和状态栏StatusStrip
工具栏和状态栏的设置与前面的菜单基本相似 1.ToolStrip 从工具栏选项卡上拖一个放入窗体即可,位置也是通过其Dock设置的.先上一张图,红色部分就是工具栏,工具栏中可以放置如图下拉菜单中的Bu ...