H
来源:互联网 发布:mac一直在大写字母 编辑:程序博客网 时间:2024/04/27 19:07
Description
Earthstone is a famous online card game created by Lizard Entertainment. It is a collectible card game that revolves around turn-based matches between two opponents. Players start the game with a substantial collection of basic cards, but can gain rarer and more powerful cards through purchasing packs of additional cards, or as rewards for competing in the arena. Card packs can be purchased with gold, an in-game currency rewarded for completing random daily quests and winning matches, or by using real money in the in-game store.
Each Earthstone battle is a one on one turn-based match between two opponents. During a player's turn, he can choose to play any of his cards and command the minions to attack targets. Those played cards will be placed on the table as they are 'summoned' as minions. Each card has two basic attributes:
- Attack Ai: If a minion attacks a character or was attacked, it will deal Ai points of damage to the opponent. A character whose attack value is zero cannot actively attack.
- Health Hi: The minion has Hi points of initial health. After being damaged, the minion's health will decrease by the corresponding damage value. The minion will be killed and discarded if its health is less than or equal to zero.If a minion attacks another minion, both of them will receive damage simultaneously.
Given two minions, please calculate the result if the first minion attacked the second one.
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
There are four integers A1, H1, A2 and H2 (0 <= A1, A2 <=10, 1 <= H1, H2 <= 10), which are the attributes of two minions.
Output
For each test case, output "Invalid" (without quotes) if the first minion cannot attack, otherwise output the minions attributes as the format in input. If the minion is killed, output "Discard" instead (without quotes).
Sample Input
33 3 2 43 2 2 50 3 2 2
Sample Output
3 1 2 1Discard 2 2Invalid
解题思路:
题意理解清楚这题就一点也不难,两个人同时受伤,看哪个死了
代码:
#include <iostream>#include<vector>#include<map>#include<string>using namespace std;int main(){ int t; cin>>t; while(t--) { int a1,h1,a2,h2; cin>>a1>>h1>>a2>>h2; if(a1==0) cout<<"Invalid"<<endl; else { h2-=a1;h1-=a2; if(h1>0&&h2>0) cout<<a1<<" "<<h1<<" "<<a2<<" "<<h2<<endl; else if(h2<=0&&h1>0) cout<<a1<<" "<<h1<<" "<<"Discard"<<endl; else { if(h1<=0&&h2>0) cout<<"Discard"<<" "<<a2<<" "<<h2<<endl; else if(h1<=0&&h2<=0) cout<<"Discard"<<" "<<"Discard"<<endl; } } } return 0;}
- h
- h
- h
- ,h
- h
- h
- H
- h
- h
- h
- H
- h
- H
- H
- h
- H
- H
- h
- 算法训练 未名湖边的烦恼
- 240. Search a 2D Matrix II(unsolved)
- react flux
- Android中RecyclerView的item运用覆盖view的方法实现item的动画效果
- 蓝桥 移动距离
- H
- 廖雪峰的Python学习笔记二-函数
- Cordova 电池状态
- 使用控制符转换进制——“投机取巧”
- 字符串与16进制字符串相互转化
- 理解JAVA程序逻辑及面向对象编程思想简单总结(1)
- ubuntu14.04安装GTX 1080 ti显卡驱动以及遇到黑屏问题
- Source Insight 宏的使用与自定义快捷键
- 知识和博弈增强的深度学习