# UVA 10415 Eb Alto Saxophone Player
## 題目連結 [UVA 10415](https://vjudge.net/problem/UVA-10415)
### 題目內容
Do you like saxophone? I have a Eb Alto Saxophone, shown on the right.
My fingers move A LOT when playing some music, and I’m quite interested in how many times each finger PRESS the button. Assume that the music is composed of only 8 kinds of note. They are:
C D E F G A B in one octave and C D E F G A B in a higher
octave. We use c,d,e,f,g,a,b,C,D,E,F,G,A,B to represent them. The fingers I use for each note are:
• c: finger 2∼4, 7∼10
• d: finger 2∼4, 7∼9
• e: finger 2∼4, 7, 8
• f: finger 2∼4, 7
• g: finger 2∼4
• a: finger 2, 3
• b: finger 2
• C: finger 3
• D: finger 1∼4, 7∼9
• E: finger 1∼4, 7, 8
• F: finger 1∼4, 7
• G: finger 1∼4
• A: finger 1∼3
• B: finger 1∼2
(Note that every finger is controlling a specified button, different fingers are controlling different buttons.) Write a program to help count the number of times each finger presses the button. A finger presses a button if it is needed in a note, but not used in the last note. Also, if it is the first note, every finger required presses the button.
### 輸入限制
The first line of the input is a single integer t (1 ≤ t ≤ 1000), indicating the number of test cases. For each case, there is only one line containing the song. The only allowed characters are {‘c’,‘d’,‘e’,‘f’,‘g’,‘a’,‘b’, ‘C’,‘D’,‘E’,‘F’,‘G’,‘A’,‘B’}. There are at most 200 notes in a song, and the song maybe empty.
### 輸出限制
For each test case, print 10 numbers indicating the number of presses for each finger. Numbers are separated by a single space.
### 解題思路
1.用map儲存每個音符需要按的指頭位置
2.這題需要注意如果上一個音符按過且這次也按,就不能重複計算
3.陣列a用來計算是否有重複
4.陣列finger用來儲存每個指頭按的次數
### 程式碼
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
string line;
int finger[11],a[11];
map<char,vector<int>>mp;
mp['c']={0,1,1,1,0,0,1,1,1,1};
mp['d']={0,1,1,1,0,0,1,1,1,0};
mp['e']={0,1,1,1,0,0,1,1,0,0};
mp['f']={0,1,1,1,0,0,1,0,0,0};
mp['g']={0,1,1,1,0,0,0,0,0,0};
mp['a']={0,1,1,0,0,0,0,0,0,0};
mp['b']={0,1,0,0,0,0,0,0,0,0};
mp['C']={0,0,1,0,0,0,0,0,0,0};
mp['D']={1,1,1,1,0,0,1,1,1,0};
mp['E']={1,1,1,1,0,0,1,1,0,0};
mp['F']={1,1,1,1,0,0,1,0,0,0};
mp['G']={1,1,1,1,0,0,0,0,0,0};
mp['A']={1,1,1,0,0,0,0,0,0,0};
mp['B']={1,1,0,0,0,0,0,0,0,0};
cin.ignore();
while(t--){
getline(cin,line);
memset(finger,0,sizeof finger);
memset(a,0,sizeof a);
for(int i=0;i<line.length();i++){
for(int j=0;j<10;j++){
if(mp[line[i]][j]==1){
if(a[j]==1){
continue;
}
else{
finger[j]++;
a[j]=1;
}
}
else{
a[j]=0;
}
}
}
for(int i=0;i<10;i++){
if(i){
cout<<" ";
}
cout<<finger[i];
}
cout<<"\n";
}
}
```
## 測資
### Sample input
3
cdefgab
BAGFEDC
CbCaDCbCbCCbCbabCCbCbabae
### Sample output
0 1 1 1 0 0 1 1 1 1
1 1 1 1 0 0 1 1 1 0
1 8 10 2 0 0 2 2 1 0
## 中文題目連結 [zerojudge e531](https://zerojudge.tw/ShowProblem?problemid=e531)