计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int whp,wat,wdef,bhp,bat,bdef; char s; int main() { while(~scanf("%c",&s)) { scanf("%d%d%d",&whp,&wat,&wdef); scanf("%d%d%d",&bhp,&bat,&bdef); int t1=wat-bdef; int t2=bat-wdef; if(s=='W') { while(1) { if(t1>0) bhp-=t1; if(bhp<=0) { printf("Warrior wins\n"); break; } if(t2>0) whp-=t2; if(whp<=0) { printf("Warrior loses\n"); break; } if(t1<=0) { printf("Warrior loses\n"); break; } } } else if(s=='B') { while(1) { if(t2>0) whp-=t2; if(whp<=0) { printf("Warrior loses\n"); break; } if(t1>0) bhp-=t1; if(bhp<=0) { printf("Warrior wins\n"); break; } if(t1<=0) { printf("Warrior loses\n"); break; } } } } return 0; }