UVA-12195 - Jingle Composing

  • 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
profile-image
Yung-Sheng Lu
Hello, I'm Yung-Sheng Lu. I am a graduate student in Department of Computer Science at National Chiao Tung University, Taiwan. I am in the Networking and Sensing Systems (NSS) Lab at NCTU.
comments powered by Disqus