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 ...
随机推荐
- ExtJS4.2学习(12)基于表格的右键菜单(转)
鸣谢:http://www.shuyangyang.com.cn/jishuliangongfang/qianduanjishu/2013-11-24/181.html --------------- ...
- org.hibernate.LazyInitializationException
1.org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.c ...
- SQL的表连接
每天给自己扫盲,让自己变得越博学. 继续学习<程序员的SQL金典>,这回我们来看看表连接相关的内容.表连接的相关知识在实际的项目开发当中,使用非常广. 所谓表连接,就是通过关联多张表,从而 ...
- 11个好用的jQuery拖拽拖放插件
这次我们整理一些拖拽播放类型的jQuery插件,这些可能不是很常用,但偶尔会有网站设计项目用到,特别是后台相关的开发项目,这个拖放排序功能一般都会有,所以适合大家收藏起来,方便日后使用.接下来一起看盾 ...
- jquery mobile validation
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content ...
- Oracle导入(imp )与导出(exp )
导出exp username/password@orcl file=db.dmp 导入imp username/password@orcl file=h:\db.dmp full=y 备注:在导入之 ...
- codeforces #313 div1 E
首先我们要注意到一个事情 如果一个灯塔向左覆盖,那么比他小的某个灯塔如果向左覆盖的端点大于当前塔向左覆盖的端点,他一定向右覆盖 对于当前灯塔向右覆盖也是同理 那么我们只需要记录当前覆盖到的端点就可以完 ...
- UR #13 Yist
第一次打UR,打了一个半小时就弃疗了QAQ 这是我唯一一道考试的时候做出来的题目,其他两道连暴力都懒得写了 很容易发现对于每个要删除的点 我们找到左边第一个比他小的不用删除的点,右边第一个比他小的不用 ...
- ORA-12704 字符集不匹配
- hadoop2.2.0安装
64位编译和安装 http://blog.csdn.net/licongcong_0224/article/details/12972889 http://blog.csdn.net/w1377026 ...