解法一
✅ 完整代碼
評分結果(參考) : AC (0.1s, 348KB)
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t, x, y, z, w, n, m;
    cin >> t;
    
    for(int i=0; i<t; i++){
        cin >> x >> y >> z >> w >> n >> m;
        cin.ignore(1, '\n');
        string s;
        getline(cin, s);
        int poison = 0;
        for(char c : s){
            if(c != ' ') m -= n*poison;
            if(m <= 0) break;
            
            switch(c){            
                case '1': m += x; break;    
                case '2': m += y; break;    
                case '3': m -= z; break;    
                case '4': m -= w; poison++; break;
            }
        }
        
        if(m <= 0) cout << "bye~Rabbit\n";
        else cout << m << "g\n";
    }
    return 0;
}