#28593: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
a271. 彩色蘿蔔 -- 兔子 | From: [203.72.60.244] | 發表日期 : 2021-12-20 11:22

#include <iostream>
#include <sstream>
using namespace std;

int main() {
int t;
cin >> t;
while (t--){
int x, y, z, w, n, m;
string s;
cin >> x >> y >> z >> w >> n >> m;
getline(cin, s);
getline(cin, s);
if (s.length()==0){
cout << m <<"g\n";
continue;
}
stringstream ss(s);
int c, b=0;
bool bye=false;
while (ss >> c){
m-=b*n;
if (m<=0){
bye=true;
break;
}
if (c==1){
m+=x;
}
else if (c==2){
m+=y;
}
else if (c==3){
m-=z;
}
else if (c==4){
m-=w;
b++;
}
if (m<=0){
bye=true;
break;
}
}
if (bye){
cout <<"bye~Rabbit\n";
}
else {
cout << m <<"g\n";
}
}
}
 
ZeroJudge Forum