-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1631.cpp
45 lines (45 loc) · 921 Bytes
/
1631.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream.h>
struct
{
char name[100];
int hp;
int power;
int amount;
int cool;
int armor;
}a,b;
void main ()
{
int k,t,a_cool,b_cool,attack_a,attack_b;
while (cin>>a.name)
{
cin>>a.hp>>a.armor>>a.cool>>a.amount>>a.power;
cin>>b.name>>b.hp>>b.armor>>b.cool>>b.amount>>b.power;
k=a.cool<b.cool?a.cool:b.cool;
t=k;
a_cool=a.cool;
b_cool=b.cool;
if (a.power-b.armor<=0) attack_a=a.amount;
else attack_a=(a.power-b.armor)*a.amount;
if (b.power-a.armor<=0) attack_b=b.amount;
else attack_b=(b.power-a.armor)*b.amount;
while (1)
{
if (t>=a.cool)
{
b.hp-=attack_a;
a.cool+=a_cool;
}
if (t>=b.cool)
{
a.hp-=attack_b;
b.cool+=b_cool;
}
if (a.hp<=0||b.hp<=0) break;
t+=k;
}
if (a.hp<=0&&b.hp<=0) cout<<"All Die!"<<endl;
else if (a.hp<=0&&b.hp>0) cout<<b.name<<" Survive!"<<endl;
else if (a.hp>0&&b.hp<=0) cout<<a.name<<" Survive!"<<endl;
}
}