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 loses
 模拟题
理解题意就好
这里我先判断可以胜利和失败的情况‘
再讨论谁先攻击的情况
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
int n;
int main ()
{
string s;
while(cin>>s)
{
int W_HP,W_ATK,W_DE;
int B_HP,B_ATK,B_DE; int F;
int D;
cin>>W_HP>>W_ATK>>W_DE;
cin>>B_HP>>B_ATK>>B_DE;
int CA=W_ATK-B_DE;
int CB=B_ATK-W_DE;
if(W_ATK<=B_DE)
{
puts("Warrior loses");
}
else if(B_ATK<=W_DE&&W_ATK>B_DE)
{
puts("Warrior wins");
}
else if(W_ATK>B_DE&&B_ATK>W_DE)
{
if(s[0]=='W')
{
int S_1=B_HP;
int S_2=W_HP;
while(S_1>0&&S_2>0)
{
S_1-=CA;
S_2-=CB;
}
if(S_1<=0)
{
puts("Warrior wins");
}
else if(S_2<=0&&S_1>0)
{
puts("Warrior loses");
}
}
else
{
int S_1=B_HP;
int S_2=W_HP;
while(S_1>0&&S_2>0)
{
S_2-=CB;
S_1-=CA;
}
if(S_2<=0)
{
puts("Warrior loses");
}
else if(S_2>0&&S_1<=0)
{
puts("Warrior wins");
}
}
}
}
return 0;
}

  

HDU计算机学院大学生程序设计竞赛(2015’12)The Magic Tower的更多相关文章

  1. hdu 计算机学院大学生程序设计竞赛(2015’11)

    搬砖 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...

  2. HDU计算机学院大学生程序设计竞赛(2015’12)Happy Value

    Problem Description In an apartment, there are N residents. The Internet Service Provider (ISP) want ...

  3. HDU计算机学院大学生程序设计竞赛(2015’12)The Country List

    Problem Description As the 2010 World Expo hosted by Shanghai is coming, CC is very honorable to be ...

  4. 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排

    1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  5. 计算机学院大学生程序设计竞赛(2015’12)Study Words

    Study Words Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  6. 计算机学院大学生程序设计竞赛(2015’12)Polygon

    Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  7. 计算机学院大学生程序设计竞赛(2015’12)The Country List

    The Country List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words

    #include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...

  9. 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower

    #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...

随机推荐

  1. TCP/IP 笔记 1.2 链 路 层

    都是包含三种类型.根据类型字段的值来进行区分 2.4 SLIP:串行线路IPS L I P的全称是Serial Line IP.它是一种在串行线路上对 I P数据报进行封装的简单形式,在RFC 105 ...

  2. ROS探索总结(五)——创建简单的机器人模型smartcar

    前面我们使用的是已有的机器人模型进行仿真,这一节我们将建立一个简单的智能车机器人smartcar,为后面建立复杂机器人打下基础. 一.创建硬件描述包 roscreat-pkg  smartcar_de ...

  3. C++对二进制文件的操作实例

    有5个学生的数据,要求: (1)将它们存放到磁盘文件中: (2)将磁盘文件中的第1,3,5个学生数据读入程序,并显示出来: (3)将第三个学生的数据修改后存回磁盘文件中的原有位置: (4)从磁盘文件读 ...

  4. Mysql GROUP_CONCAT 使用注意事项

    GROUP_CONCAT 函数返回一个字符串结果,该结果由分组中的值连接组合而成,常和 GROUP BY 连用. 如果需要自定义分隔符可以使用 SEPARATOR. 示例: SELECT GROUP_ ...

  5. matlab rand(3,5)

    rand()函数在(0,1)上创建均匀分布的随机数的数组 >> rand(3,5) ans = 0.8147 0.9134 0.2785 0.9649 0.9572 0.9058 0.63 ...

  6. IFC标准 IFCWALLSTANDARDCASE参数说明

    例如: #229= IFCWALLSTANDARDCASE('3_ydjarPr1s9tRASGqIAUD',#41,'\X2\57FA672C5899\X0\:\X2\78165899\X0\240 ...

  7. The Apache Tomcat installation at this directory is version 8.5.24 Tomcat 8.0 installation is expect

    在一台新电脑上搭建Java开发环境,JDK 是1.8,Tomcat下载了Tomcat 8.5.24,已经配置好了Java和Tomcat的环境变量,开发工具是Eclipse MARS,准备在Eclips ...

  8. Linux-shell实现阳历转农历(序)

    好些天没有登陆邮箱,前几天上班打开一看垃圾箱中有一封邮件让我好激动,还是国外友人的英文邮件.^_^大概内容是我早些时候写的一个阳历转农历的shell小程序,他在用的时候发现了bug,但是这个bug我在 ...

  9. python运算优先级

    运算符优先级(下面的优先级高) 运算符  描述 lambda  Lambda表达式 or  布尔“或”  and  布尔“与” not x   布尔“非”  in not in 成员测试 is    ...

  10. await 与 SynchronizationContext 关系

    static async Task DoStep() { //step 1 Debug.WriteLine("DoStep Start thread id: " + System. ...