日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

The Magic Tower

發布時間:2025/3/16 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The Magic Tower 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

The Magic Tower

Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0????Accepted Submission(s): 0


Problem Description Like most of the RPG (role play game), “The Magic Tower” is a game about how a warrior saves the princess.
After killing lots of monsters, the warrior has climbed up the top of the magic tower. There is a boss in front of him. The warrior must kill the boss to save the princess.
Now, the warrior wants you to tell him if he can save the princess.
Input There are several test cases.
For each case, the first line is a character, “W” or “B”, indicating that who begins to attack first, ”W” for warrior and ”B” for boss. They attack each other in turn.
The second line contains three integers, W_HP, W_ATK and W_DEF. (1<=W_HP<=10000, 0<=W_ATK, W_DEF<=65535), indicating warrior’s life point, attack value and defense value.
The third line contains three integers, B_HP, B_ATK and B_DEF. (1<=B_HP<=10000, 0<=B_ATK, B_DEF<=65535), indicating boss’s life point, attack value and defense value.

Note: warrior can make a damage of (W_ATK-B_DEF) to boss if (W_ATK-B_DEF) bigger than zero, otherwise no damage. Also, boss can make a damage of (B_ATK-W_DEF) to warrior if (B_ATK-W_DEF) bigger than zero, otherwise no damage.

Output For each case, if boss’s HP first turns to be smaller or equal than zero, please print ”Warrior wins”. Otherwise, please print “Warrior loses”. If warrior cannot kill the boss forever, please also print ”Warrior loses”.

Sample Input W 100 1000 900 100 1000 900 B 100 1000 900 100 1000 900
Sample Output Warrior wins Warrior losesAC:#include<iostream> #include<cstdio> using namespace std; int main() {int a,b,c,a1,b1,c1;char s;int l,k;while(cin>>s>>a>>b>>c>>a1>>b1>>c1){l=b-c1;k=b1-c;if(s=='W'){while(1){if(l<=0){printf("Warrior loses\n");break;}else {a1=a1-l;if(a1<=0){printf("Warrior wins\n");break;}a=a-k;if(a<=0){printf("Warrior loses\n");break;}}}}else{while(1){if(l<=0){printf("Warrior loses\n");break;}else {a=a-k;if(a<=0){printf("Warrior loses\n");break;}a1=a1-l;if(a1<=0){printf("Warrior wins\n");break;}}}}}return 0; }

總結

以上是生活随笔為你收集整理的The Magic Tower的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。