25-A Famous Music Composer

内存限制:64MB
时间限制:1000ms
Special Judge: No

accepted:4
submit:9

题目描述:

Mr. B is a famous music composer. One of his most famous work was his set of preludes. These 24 pieces span the 24 musical keys (there are musically distinct 12 scale notes, and each may use major or minor tonality). The 12 distinct scale notes are: 
 A     A#=Bb  B        C       C#=Db D       D#=Eb  E       F        F#=Gb  G       G#=Ab
Five of the notes have two alternate names, as is indicated above with equals sign. Thus, there are 17 possible names of scale notes, but only 12 musically distinct notes. When using one of these as the keynote for a musical key, we can further distinguish between major and minor tonalities. This gives 34 possible keys, of which 24 are musically distinct. 
In naming his preludes, Mr. B used all the keys except the following 10, which were named instead by their alternate names: 
 Ab minor  A# major A# minor  C# major  Db minor
 D# major  D# minor Gb major  Gb minor  G# major 
Write a program that, given the name of a key, give an alternate name if it has one, or report the key name is unique. 

输入描述:

Each test case is described by one line having the format "note tonality", where "note" is one of the 17 names for the scale notes given above, and "tonality" is either "major" or "minor" (quotes for clarify). 

输出描述:

For each case output the required answer, following the format of the sample.

样例输入:

复制

Ab minor
D# major
G minor

样例输出:

Case 1: G# minor
Case 2: Eb major
Case 3: UNIQUE 题目大意:
  ①、每一行,给你两个字符串,判断第一个字符串是否属于表格一中有“=”符号的字符串,属于就输出与之相同的字符串,至于第二个字符串,照抄下来就行了,但是如果不属于有“=”连接的字符串,就要输出UNIQUE 分析:
  ①、我们可以看出具有“=”关系的前三个字符第一个元素差1,而第二个相对固定,酱紫考虑问题就简洁很多了 核心代码:  
 if(s1[] == '#')
{
if(s1[] == 'G')
printf("Ab %s\n", s2);
else
printg("%cb %s\n", s1[]+, s2);
}
else if(s1[] == 'b')
{
if(s1[] == 'A')
printf("G# %s\n", s2);
else
printf("%c# %s\n", s1[]-, s2);
}
else
{
printf("UNIQUE\n");
}

C/C++代码实现(AC):

 #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack> using namespace std; int main ()
{
char s1[], s2[];
int cnt = ;
while(~scanf("%s %s", &s1[], &s2[]))
{
printf("Case %d: ", cnt ++);
if(s1[] == '#')
{
if(s1[] == 'G')
{
printf("Ab %s\n", s2);
}
else
{
printf("%cb %s\n", s1[]+, s2);
}
}
else if(s1[] == 'b')
{
if(s1[] == 'A')
{
printf("G# %s\n", s2);
}
else
{
printf("%c# %s\n", s1[]-, s2);
}
}
else
{
printf("UNIQUE\n");
}
}
return ;
}

nyoj 25-A Famous Music Composer(字符串)的更多相关文章

  1. NYOJ 25 A Famous Music Composer

    A Famous Music Composer 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 Mr. B is a famous music composer. O ...

  2. 25.A Famous Music Composer

    描述 Mr. B is a famous music composer. One of his most famous work was his set of preludes. These 24 p ...

  3. 07-语言入门-07-A Famous Music Composer

    题目地址: http://blog.csdn.net/sevenmit/article/details/8231994  描述 Mr. B is a famous music composer. On ...

  4. A Famous Music Composer

    描述 Mr. B is a famous music composer. One of his most famous work was his set of preludes. These 24 p ...

  5. nyoj25-A Famous Music Composer

    A Famous Music Composer 时间限制:1000 ms  |  内存限制:65535 KB 难度:1 描述 Mr. B is a famous music composer. One ...

  6. NYOJ 305 表达式求值 (字符串处理)

    题目链接 描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20 ,add(10,98) 的值是108等等.经过训练, ...

  7. NYOJ 35 表达式求值 (字符串处理)

    题目链接 描述 ACM队的mdd想做一个计算器,但是,他要做的不仅仅是一计算一个A+B的计算器,他想实现随便输入一个表达式都能求出它的值的计算器,现在请你帮助他来实现这个计算器吧. 比如输入:&quo ...

  8. PAT A1110 Complete Binary Tree (25 分)——完全二叉树,字符串转数字

    Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each in ...

  9. PAT A1028 List Sorting (25 分)——排序,字符串输出用printf

    Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...

随机推荐

  1. [插件化开发] Poc之后,我选择放弃OSGI

    Poc之后,我选择放弃OSGI TIPS: 如贵司允许重构老系统或者允许使用OSGI的第三方框架改造所带来的投入成本,并且评估之后ROI乐观,那么还是可以使用的. Runtime Version 以下 ...

  2. php和apache的关系是什么?

    例如我们在自己的电脑里练习如何做网站的时候,我们需要搭建一个本地环境,这个本地环境就是PHP+APACHE + MYSQL的环境,这样就可以让我们的电脑拥有PHP要求的运行环境了.那么php和apac ...

  3. MS09-012 PR提权

     漏洞编号:MS09-012 披露日期: 2009/4/14 受影响的操作系统:Windows 2008 x64 x86;XP;Server 2003 sp1 sp2; 测试系统:windows 20 ...

  4. pytest4-单文件使用fixture(Fixtures as Function arguments)

    Fixtures as Function arguments (fixture作为函数参数传入)Test functions can receive fixture objects by naming ...

  5. Python编程系列---Python中装饰器的几种形式及万能装饰器

    根据函数是否传参  是否有返回值 ,可以分析出装饰器的四种形式: 形式一:无参无返回值 def outer(func): def wrapper(): print("装饰器功能1" ...

  6. 面试必问的Synchronized知道这些就可以了

    Synchronized关键字算是Java的元老级锁了,一开始它撑起了Java的同步任务,其用法简单粗暴容易上手.但是有些与它相关的知识点还是需要我们开发者去深入掌握的.比如,我们都知道通过Synch ...

  7. 设计模式(九)Bridge模式

    Bridge模式就是将类的功能层次结构和类的实现层次结构连接起来. 类的功能层次结构就是根据实际非抽象类来说的,也就是父类具有基本功能,然后在子类中增加新功能.用于增加新功能. 类的实现层次结构就是根 ...

  8. mysql的一些常用操作(一)

    1.启动Mysql服务 net start mysql 2.进入mysql环境中,由于自己没有设置密码,直接回车进入即可(要将bin加入到环境变量path中) mysql -u root -p 3.创 ...

  9. 从java到python

    从java到python 从事java开发主要是web方向,这个方向已经相当成熟,基本你想开发什么样的app,总能百度出来相关的项目或者github中搜索到,你需要做的就是掌握调试的技巧,基本你能想到 ...

  10. Head First设计模式——简单工厂、工厂、抽象工厂

    前言:按照惯例我以Head First设计模式的工厂模式例子开始编码学习.并由简单工厂,工厂模式,抽象工厂模式依次演变,归纳他们的相同与不同. 话说Head First认为简单工厂并不是设计模式,而是 ...