HDU 6913 Chord(“红旗杯”第十四届吉林省大学生程序设计竞赛 )

Problem Description

Lvat is studying music. In this week, he has to figure out what chords are. First of all, he needs to learn the two kinds of most basic chords - the major triad chord and the minor triad chord.

In music theory, every 12 successive notes form a loop (or formally, an octave). Practically, we denote each note in an octave from low to high as C, C#, D, D#, E, F, F#, G, G#, A, A# and B. The pitch distance between every two adjacent notes is the same,which is called a semitone. Specifically,thepitchdistance between note C in the higher octave and note B in the adjacent lower octave is also one semitone. To conceptualize this, we can mark them on the piano keyboard, one key one note, as the figure shown below. As mentioned, the pitch distance between every two adjacent key is one semitone:
 



Now Lvat can easily make out the two kinds of most basic chords. You can think of a chord simply as a group of different notes. Specifically, the major triad chord and the minor triad chordare both composed of three different notes, and we denote them from low to high as N1,N2 and N3:

⋅ If the pitch distance between N1 and N2 is exactly 4 semitones, and that between N2 and N3 is exactly 3 semitones, we call the group of notes a major triad chord.

⋅ If the pitch distance between N1 and N2 is exactly 3 semitones, and that between N2 and N3 is exactly 4 semitones, we call the group of notes a minor triad chord.

For example, consider a group of notes of <N1 = C, N2 = E, N3 = G> in the same octave. Note C and note E have a pitch distance of 4, while note E and note G have a pitch distance of 3, so it is a major triad chord.

Next consider a group of notes of <A, C, E>, where note A is in the lower octave, and note C and E are in the adjacent higher octave. Note A and note C have a pitch distance of 3, while note C and note E have a pitch distance of 4, so it is a minor triad chord.

Now Lvat needs you to help him decide which groups of notes are major triads and which ones are minor triads.

Input

The first line is a single number T (T ≤ 2000), indicating the number of groups of notes.

For the following T lines, each line contains a group of three notes N1,N2 and N3 (denoted as described before), separated by a single space. It is guaranteed that the three notes are given from low to high, and the pitch distance between N1 and N2 is no more than 11 semitones, so is N2 and N3.

Output

Output T lines.

The i-th line indicates the answer for the i-th group of notes. If the i-th group constitutes a major triad chord, output “Major triad” (without quotation marks), or if it constitutes a minor triad chord, output “Minor triad” (without quotation marks), otherwise output “Dissonance” (without quotation marks).

Sample Input

5 C E G A C E B D F# C F A E D C

Sample Output

Major triad Minor triad Minor triad Dissonance Dissonance

题意:给定三个音符判断这三个音符是否构成大三和弦或小三和弦;

步骤:

        1、将三个八度的音符以字符串数组形式存储

        2、每次读入三个需要判断的音符,依次与存储的数组进行比较,并记录相邻两个音符的间隔

        3、与给定条件进行比较

AC代码:

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

string s[]={"C","C#","D","D#","E","F","F#","G","G#","A",
"A#","B","C","C#","D","D#","E","F","F#","G","G#","A","A#",
"B","C","C#","D","D#","E","F","F#","G","G#","A","A#",
"B"};
string n1,n2,n3;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		cin>>n1>>n2>>n3;
		int cnt1,cnt2;
		int i=0;
		for(;;i++)
			if(s[i]==n1)
				break;
		for(int j=i+1;;j++)
			if(s[j]==n2)
		{
			cnt1=j-i;
			i=j;
			break;
		}
		for(int j=i+1;;j++)
			if(s[j]==n3)
		{
			cnt2=j-i;
			i=j;
			break;
		}
		if(cnt1==4&&cnt2==3)
			puts("Major triad");
		else if(cnt1==3&&cnt2==4)
			puts("Minor triad");
		else 
			puts("Dissonance");
	}
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Double.Qing

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值