1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include<iostream> #include<sstream> #include<string>
using namespace std;
int main(){ int dataNum=0; stringstream stream;
string s; int temp; int poison=0; bool isLife=true;
cin>>dataNum; s="\n";getline(cin,s); for(int i=0;i<dataNum;i++){ isLife=true; int x,y,z,w,n,m;
s=""; getline(cin,s);
stream.clear(); stream.str(""); stream<<s; stream>>x>>y>>z>>w>>n>>m; s=""; getline(cin,s); if(s!=""){ poison=0; temp=0;
stream.clear(); stream<<s; while(stream>>temp){ m-=poison*n; if(m<=0){ isLife=false; break; }
if(temp==1){ m+=x; }else if(temp==2){ m+=y; }else if(temp==3){ m-=z; if(m<=0){ isLife=false; break; } }else if(temp==4){ m-=w; if(m<=0){ isLife=false; break; } poison+=1; } } if(isLife){ cout<<m<<"g"<<endl; }else{ cout<<"bye~Rabbit"<<endl; } }else{ cout<<m<<"g\n"; } } return 0; }
|