HDU2015校赛 The Magic Tower
题意:两行分别是W和B的生命值,攻击值,防御值。
如果W先,W的攻击值-B的防御值大于零则B生命值减去这么多,然后该B攻击。直到谁的生命值先小与等于零则攻击的人赢。
输出写错了。。。。。
错误代码
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<string.h>
#include<algorithm>
using namespace std;
char c;
int w[],b[]; int main()
{
while(~scanf("%c",&c))
{
for(int i=; i<; i++)
scanf("%d",&w[i]);
for(int i=; i<; i++)
scanf("%d",&b[i]);
if(c=='W')
{
int ans=w[]-b[];
if(ans<=)
{
printf("Warrior loses\n");
continue;
}
while(b[]>&&w[]>)
{
ans=w[]-b[];
if(ans>)
b[]-=ans;
if(b[]<=)
{
printf("Warrior wins\n");
break;
}
else
{
ans=b[]-w[];
if(ans<=)
{
printf("Warrior wins\n");
break;
}
w[]-=ans;
if(w[]<=)
{
printf("Warrior loses\n");
break;
}
}
}
}
else
{
int ans=b[]-w[];
if(ans<=)
{
printf("Warrior wins\n");
continue;
}
while(b[]>&&w[]>)
{
ans=b[]-w[];
if(ans>)
w[]-=ans;
if(w[]<=)
{
printf("Warrior loses\n");
break;
}
else
{
ans=w[]-b[];
if(ans<=)
{
printf("Warrior loses\n");
break;
}
b[]-=ans;
if(b[]<=)
{
printf("Warrior wins\n");
break;
}
}
}
}
}
return ;
}
AC代码
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<string.h>
#include<algorithm>
using namespace std;
char c;
int w[],b[]; const int maxn=1e5+;
int main(){
char str[];
while(~scanf("%s",str)){
int a1,a2,a3,b1,b2,b3;
scanf("%d%d%d%d%d%d",&a1,&a2,&a3,&b1,&b2,&b3);
if(a2-b3<=&&b2-a3<=){
printf("Warrior loses\n");
continue;
}
if(str[]=='W'){
int flag=;
while(a1>&&b1>){
if(flag==){
b1-=(a2-b3);
flag=;
}else{
a1-=(b2-a3);
flag=;
}
}
if(a1<=)printf("Warrior loses\n");
else printf("Warrior wins\n");
}else{
int flag=;
while(a1>&&b1>){
if(flag==){
a1-=(b2-a3);
flag=;
}else{
b1-=(a2-b3);
flag=;
}
}
if(a1<=)printf("Warrior loses\n");
else printf("Warrior wins\n");
}
}
return ;
}
HDU2015校赛 The Magic Tower的更多相关文章
- HDU2015校赛 The Country List
今天手感真差..各种读错题意.水题... 就是说,给你几个串.如果长度一样并且相同位置字符相同(不分大小写)的个数大于两个就是不同串. #include<iostream> #includ ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree
// 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...
- SCNU省选校赛第二场B题题解
今晚的校赛又告一段落啦,终于"开斋"了! AC了两题,还算是满意的,英语还是硬伤. 来看题目吧! B. Array time limit per test 2 seconds me ...
- 2014上半年acm总结(1)(入门+校赛)
大一下学期才开始了acm,不得不说有一点迟,但是acm确实使我的生活充实了很多,,不至于像以前一样经常没事干= = 上学期的颓废使我的c语言学的渣的一笔..靠考前突击才基本掌握了语法 寒假突然醒悟, ...
- 2017CUIT校赛-线上赛
2017Pwnhub杯-CUIT校赛 这是CUIT第十三届校赛啦,也是我参加的第一次校赛. 在被虐到崩溃的过程中也学到了一些东西. 这次比赛是从5.27早上十点打到5.28晚上十点,共36小时,中间睡 ...
- HZNU第十二届校赛赛后补题
愉快的校赛翻皮水! 题解 A 温暖的签到,注意用gets #include <map> #include <set> #include <ctime> #inclu ...
- 校赛F
问题描述 例如对于数列[1 2 3 4 5 6],排序后变为[6 1 5 2 4 3].换句话说,对于一个有序递增的序列a1, a2, a3, ……, an,排序后为an, a1, an-1, a2, ...
- PKU2018校赛 H题 Safe Upper Bound
http://poj.openjudge.cn/practice/C18H 题目 算平均数用到公式\[\bar{x}=\frac{x_1+x_2+x_3+\cdots+x_n}{n}\] 但如果用in ...
随机推荐
- PAT-乙级-1035. 插入与归并(25)
1035. 插入与归并(25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 根据维基百科的定义: 插入排序是迭 ...
- hdu 3952
因为一个小错 不过 好不爽........ #include <iostream> #include <fstream> using namespace std; struc ...
- firefly服务器间通信演示
源地址:http://www.9miao.com/question-15-54560.html 最近好多童鞋都在问firefly几个服务器之间是如何通信的,其实在之前的distributed使用文档中 ...
- php的redis 操作类,适用于单台或多台、多组redis服务器操作
redis 操作类,包括单台或多台.多组redis服务器操作,适用于业务复杂.高性能要求的 php web 应用. redis.php: <?php /* redis 操作类,适用于单台或多台. ...
- Qt: 内建对话框(各种对话框都有了,且用到了qobject_cast解析sender的技术)
#include "BuiltinDialog.h" #include <QtGui/QTextEdit> #include <QtGui/QPushButton ...
- 190. Reverse Bits
题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented ...
- 《 UNIX网络编程》源码的使用
学习编程这东西,看代码,改代码,运行代码这样才能学到实际东西!本书说在www.unpbook.com可以获取源码,不过打不开!所以google unpv13e.tar.gz 并在网络上找到了:源码:h ...
- UML各种图画法总结
<UML 2.4.1 教程> http://www.sparxsystems.cn/resources/uml2_tutorial/ <UML总结(对九种图的认识和如何使用Ratio ...
- javascript里的post和get有什么区别
FORM中的get post方法区别Form中的get和post方法,在数据传输过程中分别对应了HTTP协议中的GET和POST方法.二者主要区别如下: 1.Get是用来从服务器上获得数据,而Post ...
- 【开源推荐】AllJoyn:打造全球物联网的通用开源框架
摘要:随着智能设备的发展,物联网逐渐进入了人们的生活.据预测,未来几乎一切东西(超过500亿台设备)都可以互联.高通公司发布了开源项目AllJoyn,这是一个能够使连接设备间进行互操作的通用软件框架和 ...