Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- main(){
- int coba;
- cin>>coba;
- for (int i=0; i<coba; i++) {
- int h,c,m,o,a;
- cin>>h; cin>>c; cin>>m; cin>>o; cin>>a;
- int mario=0, mons=0, obat=0;
- // obat>damage monster
- if (m<=a){
- while ((o>0) && (h>0)) {
- o=o-c;
- mario++;
- h=h-a;
- mons++;
- if (h<=0) {
- cout<<"IMPOSSIBLE"<<endl;
- } else if (o<=0) {
- cout<<"POSSIBLE"<<endl;
- cout<<"SERANG "<<mario<<endl;
- cout<<"OBAT "<<obat<<endl;
- }
- }
- } else if (m>a) {
- while (o>0){
- if (c>=o) {
- o=o-c;
- mario++;
- }
- else if (h>a) {
- o=o-c;
- mario++;
- if (o<=0) break;
- h=h-a;
- mons++;
- } else if (h<=a) {
- h=h+m;
- obat++;
- h=h-a;
- mons++;
- }
- }
- cout<<"POSSIBLE"<<endl;
- cout<<"SERANG "<<mario<<endl;
- cout<<"OBAT "<<obat<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement