UVA-12195 - Jingle Composing
13 Apr 2018
- UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt。
- 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
- 本題選為「20170523 大學程式能力檢定 CPE」題目。
題意概要
題目會給定一首曲子,且每一段以 /
分段,其中每一段的內的每個音符都有一個拍數 (如下表),而題目希望能求得每一段的音符拍樹之總和為 ,即符合題目題目所求的「好段」,所求為整首曲子符合「好段」的段數。
- 分析:本題為簡單的模擬題,每一個段落 (以
/
分段) 的音符拍數總和為 ,即符合題目所求。提示:可以將題目給定每個音符的拍數全部乘上 方便計算,而判斷拍數加總的部分要改為 才符合題目所求。
Input
The input contains several test cases. Each test case is described in a single line containing a string whose length is between and characters, inclusive, representing a composition. A composition begins and ends with a slash /
. Measures in a composition are separated by a slash /
. Each note in a measure is represented by the corresponding uppercase letter, as described above. You may assume that each composition contains at least one measure and that each measure contains at least one note.
All characters in the input will be either slashes or one of the seven uppercase letters used to represent notes, as described above. The last test case is followed by a line containing a single asterisk.
Output
For each test case your program must output a single line, containing a single integer, the number of measures that have the right duration.
Sample Input
/HH/QQQQ/XXXTXTEQH/W/HW/
/W/W/SQHES/
/WE/TEX/THES/
*
Sample Output
4
3
0