zoukankan      html  css  js  c++  java
  • hdoj 4245 水题之A Famous Music Composer

    A Famous Music Composer

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 216    Accepted Submission(s): 129


    Problem Description
    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:


    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:


    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.
     
    Input
    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).
     
    Output
    For each case output the required answer, following the format of the sample.
     
    Sample Input
    Ab minor D# major G minor
     
    Sample Output
    Case 1: G# minor Case 2: Eb major Case 3: UNIQUE
     
    Source
     
     因为题目太简单了 主要是题意丕好理解 果断水掉了 water~~~~
    View Code
     1 #include <iostream>
     2 #include <map>
     3 #include <cstdio>
     4 #include <string>
     5 using namespace std;
     6 
     7 int main()
     8 {
     9     map <string,string>m;
    10     m["A#"]="Bb";
    11     m["Bb"]="A#";
    12                 m["C#"]="Db";    m["Db"]="C#";
    13                 m["D#"]="Eb";    m["Eb"]="D#";
    14                 m["F#"]="Gb";m["Gb"]="F#";
    15                 m["G#"]="Ab";    m["Ab"]="G#";
    16                 string s1,s2;
    17                 int sum=1;
    18                 while(cin>>s1>>s2)
    19                 {
    20                                     cout<<"Case "<<sum++<<": ";
    21                                     if (m.count(s1))
    22                                     {
    23                                       cout<<m[s1]<<" "<<s2<<endl;
    24                                     }
    25                                     else cout<<"UNIQUE"<<endl;
    26                 }
    27                 
    28                 
    29                 return 0;
    30 }
  • 相关阅读:
    哈希表,开放地址法之线性探测代码(JAVA)
    Java中几个关键字的意思
    java学习——File类操作
    Map三种遍历方法
    Spring Data Binding
    哈希表的基础理解
    选择排序
    map集合使用
    排序
    关于LinkedList
  • 原文地址:https://www.cnblogs.com/wujianwei/p/2598618.html
Copyright © 2011-2022 走看看