2016年10月10日 星期一

Q:10415 - Eb Alto Saxophone Player

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1356

這題是2016 10/06 CPE題目 我的解法是先把14個按鍵方法先存入陣列中(arr)再建立一個整數陣列把按鈕轉換成配對arr的索引值 例如hash['c']=0(c紐就配對arr[0])
最後就是一個字一個字讀取並且依序檢查是否有按過 案過之後state[]=1反之
if (ary[j] == '1' && state[j] == 0) {
ans[j]++;
state[j] = 1;
}
if (ary[j] == '0')

state[j] = 0;

沒有留言:

張貼留言