UVA - 10785 The Mad Numerologist
这个题又犯了省题不清的错误。导致不停 wa。唉。
题目意思是给你一个长度L,然后和一张表相应每一个大写字母的value值。你须要依照一定规则找出长度为L的序列。
注意 序列的value值要最小,而且须要按字典序排,就是按字典序排,一直没意识到,事实上在依据value值选出最小序列之后,还要分别排序,这样得出的才是字典序最小的序列。
知道这个就分别找出元音和辅音的序列然后排序就可以。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char ss[]="JSBKTCLDMVNWFXGPYHQZR";
char s[]="AUEOI"; int cmp(const void* a,const void* b)
{
char* _a=(char*) a;
char* _b=(char*) b;
return *_a-*_b;
}
int main()
{
freopen("a.txt","r",stdin);
char s1[200],s2[200];
int t,n,i,j=1;
scanf("%d",&t);
while(t--)
{
memset(s1,'\0',sizeof(s1));
memset(s2,'\0',sizeof(s2));
printf("Case %d: ",j++);
scanf("%d",&n);
int l1=0,l2=0;
int x=0,y=0;
int c1=0,c2=0;
for(i=0;i<n/2;i++)
{
s1[l1++]=s[x];
s2[l2++]=ss[y];
c1++;c2++;
if(c1==21)
{
c1=0;
x++;
}
if(c2==5)
{
c2=0;
y++;
}
}
if(n/2) s1[l1++]=s[x];
qsort(s1,l1,sizeof(char),cmp);
qsort(s2,l2,sizeof(char),cmp);
for(i=0;i<n/2;i++)
{
printf("%c%c",s1[i],s2[i]);
}
if(n/2) printf("%c",s1[n/2]);
printf("\n");
}
return 0;
}
UVA - 10785 The Mad Numerologist的更多相关文章
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- Volume 1. Sorting/Searching(uva)
340 - Master-Mind Hints /*读了老半天才把题读懂,读懂了题输出格式没注意,结果re了两次. 题意:先给一串数字S,然后每次给出对应相同数目的的一串数字Si,然后优先统计Si和S ...
- 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)
第一题:340 - Master-Mind Hints UVA:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Item ...
- uva 10222 - Decode the Mad man
#include <iostream> #include <string> #include <cctype> using namespace std; int m ...
- Lesson 21 Mad or not?
Text Aeroplanes are slowly driving me mad. I live near an airport and passing planes can be heard ni ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
随机推荐
- php几个比较高级的函数
1.传递任意数量的函数参数 我们在.NET或者JAVA编程中,一般函数参数个数都是固定的,但是PHP允许你使用任意个数的参数.下面这个示例向你展示了PHP函数的默认参数: 1 2 3 4 5 6 7 ...
- MyEclipse使用经验总结
0.快捷键 ================================================================================ 编辑: Ctrl+Shif ...
- windows下使用cxfreeze打包python3程序
1:下载适合版本的cxfreeze http://sourceforge.net/projects/cx-freeze/files/4.3.2/ 2:安装,注意python版本是否正确 3:安装完成后 ...
- iOS: performSelectorOnMainThread(译)
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)waitperfor ...
- C语言存储类型及各存储类型作用域和生存域比较
c语言中的存储类型有`auto`, `extern`, `register`,`static` 这四种,存储类型说明了该变量要在进程的哪一个段中分配内存空间,可以为变量分配内存存储空间的有数据区.BB ...
- jq实现瀑布流效果
<!doctype html><html><head><meta http-equiv="Content-Type" content=&q ...
- [原创]dm642_HPI调通并boot成功
一直在折腾前段时间画好的dm642+lpc4357板子,说明下这个板子的结构: 主芯片为DM642,这个片子很老了,但因为对这个片子熟悉,别折腾 没有给DM642加FLASH,配了一片LPC4357, ...
- asp.net学习
http://www.cnblogs.com/fish-li/archive/2011/12/27/2304063.html
- tyvj 1342 教主泡嫦娥 环上DP
342 教主泡嫦娥 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 2012年12月21日下午3点14分35秒,全世界各国的总统以及领导人都已经汇聚在中国的方 ...
- nodejs and db
http://blog.nosqlfan.com/tags/nodejs http://www.cnblogs.com/windwithlife/archive/2013/02/25/2923235. ...