-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP10528.java
51 lines (45 loc) · 1.23 KB
/
P10528.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.*;
import java.util.*;
public class P10528 {
public static final String[] TONES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
//public static final int[] SPACE = {0, 2, 4, 5, 7, 9, 11};
public static final int[] NON_SPACE = {1, 3, 6, 8, 10};
public static void main(String[] args) throws Exception {
Map<String,Integer> map = new TreeMap<String,Integer>();
for(int i = 0; i < TONES.length; ++i)
map.put(TONES[i], i);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true) {
// read input:
String line = br.readLine().trim();
if(line.equals("END"))
return;
String[] parts = line.split("\\s+");
// Compute hit nodes:
boolean[] hit = new boolean[12];
for(String part : parts) {
if(!part.isEmpty())
hit[map.get(part)] = true;
}
// output:
boolean first = true;
for(int i = 0; i < 12; ++i) {
// Check accord:
boolean ok = true;
for(int nonSpace : NON_SPACE) {
if(hit[(i + nonSpace)%12]) {
ok = false;
break;
}
}
if(ok) {
if(!first)
System.out.print(" ");
System.out.print(TONES[i]);
first = false;
}
}
System.out.println();
}
}
}