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. 【转】Sublime Text2中的快捷键一览表(Sublime 键盘快捷键大全 )

    Sublime Text 提供了无比强大的快捷键阵容,如果能够在Coding的时候灵活的使用快捷键,将能够使得你的效率倍增,相信在不久的将来,Sublime Text将是你跨平台使用的最佳Coding ...

  2. volatile关键字在多线程中的作用

  3. 读书笔记<深入理解JVM>01 关于OutOfMemoryError 堆空间的溢出

    代码片段如下: package com.gosaint.shiro; import java.util.ArrayList; import java.util.List; public class H ...

  4. Codeforces #505(div1+div2) B Weakened Common Divisor

    题意:给你若干个数对,每个数对中可以选择一个个元素,问是否存在一种选择,使得这些数的GCD大于1? 思路:可以把每个数对的元素乘起来,然后求gcd,这样可以直接把所有元素中可能的GCD求出来,从小到大 ...

  5. C++对ASCII文件的操作例子

    从键盘读入一行字符,把其中的字母字符依次放在磁盘文件f2.dat中,再把它从磁盘文件读入程序,将其中的小写字母改写成大写字母,再存入磁盘文件f3.dat. code: #include<iost ...

  6. Etyma01 ced ceed cess

    一. etyma ['ɛtə,mə] ced.ceed.cess -> go -> 行走,前进 二.for instance 1. precede=pre+ced+e pre- 在前 2. ...

  7. UltraISO制作系统ISO镜像

    一.简介 UltraISO是一款功能强大而又方便实用的光盘映像文件制作/编辑/转换工具,它可以直接编辑ISO文件和从ISO中提取文件和目录,也可以从CD-ROM制作光盘映像或者将硬盘上的文件制作成IS ...

  8. Linq 和 Lambda 查询中按照多个值进行分组GroupBy

    创建要查询的对象: class Employee { public int ID { get;set; } public string FName { get; set; } public int A ...

  9. 继承&多态

    继承: 概念: 基类,超累,父类 访问权限: Public :无限制,自由访问 Private:不可继承 protected :包内,包外,可访问,继承 default:没有指明任何权限下,默认在同一 ...

  10. A Plug for UNIX UVA - 753(网络流)

    题意:n个插座,m个设备及其插头类型,k种转换器,没有转换器的情况下插头只能插到类型名称相同的插座中,问最少剩几个不匹配的设备 lrj紫书里面讲得挺好的. 先跑一遍floyd,看看插头类型a能否转换为 ...