CodeForces - 903B暴力java

刚开始审题不清,成功WA了好几次

哎还是要好好读题啊~~~

此题有几个注意点:

   1.我在一回合内喝药,对面怪也会打我,所以一回合可以加(c1-a2)的血量

   2.我总是比怪物多行动一个回合!!!我想赢的话!

import java.util.Scanner;
//注:我总是比对面的怪物多行动一次!!!
public class Main20 {
	public static Scanner sc=new Scanner(System.in);

	public static void main(String[] args) {
		while(sc.hasNext()) {
			int h1=sc.nextInt();
			int a1=sc.nextInt();
			int c=sc.nextInt();
			int h2=sc.nextInt();
			int a2=sc.nextInt();
			int i=1;
			//判断我在多少个回合可以杀死怪物:
			while(i*a1<h2)
				i++;
			//判断怪物是否可以在(i-1)个回合杀死我
			if((i-1)*a2<h1) {
				System.out.println(i);
				while(i-->0)
					System.out.println("STRIKE");
			}
			//如果怪物正好在我的i回合(即我最后一次攻击之前)可以杀死我
			//那么由于c1>a2,所以我只需喝一次药
			else if((i-1)*a2==h1) {
				System.out.println(i+1);
				System.out.println("HEAL");
				while(i-->0)
					System.out.println("STRIKE");
			}
			//这个就是如果前面两种都不满足,那么我可以先喝药到可以撑过怪物的(i-1)轮次攻击
			else {
				int h=1;
				int result=c+h1-a2;
				while(result<=(i-1)*a2) {
					result=result+c-a2;
					h++;
				}
				System.out.println(h+i);
				while(h-->0)
					System.out.println("HEAL");
				while(i-->0)
					System.out.println("STRIKE");
			}
		}
	}
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值