题目链接

这个题又犯了省题不清的错误。导致不停 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的更多相关文章

  1. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  2. Volume 1. Sorting/Searching(uva)

    340 - Master-Mind Hints /*读了老半天才把题读懂,读懂了题输出格式没注意,结果re了两次. 题意:先给一串数字S,然后每次给出对应相同数目的的一串数字Si,然后优先统计Si和S ...

  3. 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)

    第一题:340 - Master-Mind Hints UVA:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Item ...

  4. uva 10222 - Decode the Mad man

    #include <iostream> #include <string> #include <cctype> using namespace std; int m ...

  5. Lesson 21 Mad or not?

    Text Aeroplanes are slowly driving me mad. I live near an airport and passing planes can be heard ni ...

  6. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  7. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  8. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  9. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

随机推荐

  1. struts2 package元素

    <package../>元素         name         必选    包名         extends     可选    继承         namespace    ...

  2. java 使用substring 截取特殊字符串的后一位或者数字

    关于截取特殊的字符串的后一位或者数字 需求:截取特殊字符为  .   后一位 String[] str = uri.split("/"); String str1 = str[st ...

  3. jQuery获取Select选择的Text和 Value

    jQuery获取Select选择的Text和Value:语法解释:1. $("#select_id").change(function(){//code...});   //为Se ...

  4. Python 基础-python环境变量、模块初识及字符类型

    (1).模块内置模块.第三方模块.自定义模块初识模块:sys \ os一般标准库存放路径 C:\Users\Administrator\AppData\Local\Programs\Python\Py ...

  5. 【python】二进制、八进制、十六进制表示方法(3.0以上)

    2进制是以0b开头的: 例如: 0b11 则表示十进制的3 8进制是以0o开头的: 例如: 0o11则表示十进制的9 (与2.0版本有区别) 16进制是以0x开头的: 例如: 0x11则表示十进制的1 ...

  6. uboot内存分布

    一.uboot的内存分布图 山人自己画的图 华清远见的图 二.如何修改编译地址 board/smdk2410/config.mk中定义有TEXT_BASE TEXT_BASE = 0x33F80000 ...

  7. myeclipse 添加服务器运行时环境

    像servlet-api.jar.servlet-api.jar服务器能提供的包 解决方法如下: 1,File->New->Other->Server->Server(注意在n ...

  8. C语言怎么计算程序所花时间

    在函数之前和之后取得系统的时间,然后相减就是函数执行时间,不过在取得系统时间的时候,最小单位是微秒 具体代码如下: #include<stdio.h> #include<iostre ...

  9. 【HDOJ】3789 奥运排序问题

    写了个函数指针,这题目很水,但是佷烦. #include <iostream> #include <cstring> #include <cstdio> #incl ...

  10. HDOJ/HDU 1250 Hat's Fibonacci(大数~斐波拉契)

    Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequen ...