No.1109 調の判定
タグ : / 解いたユーザー数 324
作問者 :
trineutron
/ テスター :
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
Orion is going to perform a choral piece. For this purpose, he has decided to determine the key of the piece. Analyzing the piece, he found that it uses a major scale and consists of the notes $T_1, T_2, \dots, T_N$. Determine the key of this piece and print the integer at least $0$ and less than $12$ that represents the key. If no such integer exists, or if more than one exists, print $-1$ instead. Here, when the key is $D$, the notes contained in the major scale are $\{ D, D+2, D+4, D+5, D+7, D+9, D+11 \} \pmod{12}$.
(Added 2020/07/10 22:07) When the key is $D$, the only notes that may be used are $D, D+2, D+4, D+5, D+7, D+9, D+11$, and it is possible that not all of them are used.
Input
$N$ $T_1\ T_2\ \dots\ T_N$
All inputs are integers.
$1 \le N \le 12$
$0 \le T_i < 12$
If $i < j$, then $T_i < T_j$
Output
If the key can be uniquely determined, print the integer at least $0$ and less than $12$ that represents the tonic of that key; otherwise, print $-1$. Print a newline at the end.
Sample
Sample 1
Input
5 0 2 6 7 11
Output
7
Sample 2
Input
3 2 6 10
Output
-1
There is no key that contains all of the notes $2, 6, 10$.
Sample 3
Input
5 0 2 4 7 9
Output
-1
There are 3 possible keys: $0, 5, 7$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。