LuoguP1785 漂亮的绝杀 题解

Content

因太占排版,请自己去题面查看。

Solution

声明:以下和题面相同的变量的意义均和题面相同。

这个题目 \(\texttt{if}\) 操作很多,其他的就是纯模拟。

首先,我们先判断数据是否有错误。判断完如果有错误直接结束,没错误继续判断。

判断绝杀,只需判断 \(2z\geqslant x\) 是否成立,这里倒很显然不需多讲。

然后能绝杀的话进入下一部分:能否完胜。

我们先求出绝杀要用的攻击次数 \(t\),然后我们可以依次求出用三星嗜血、四星嗜血和五星嗜血后的血量。分别为 \(y+t\times\left\lfloor z\times0.33\right\rfloor\)\(y+t\times\left\lfloor z\times0.5\right\rfloor\)\(y+tz\),由于由题面可以知道,企鹅满血血量为 \(315\),所以从三星嗜血开始依次判断是否是满血即可。

如果不行,直接输出四星嗜血后的血量时,直接套用上面的公式就好。

Code

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

int x, y, z, times;

int main() {
	scanf("%d%d%d", &x, &y, &z);
	if(y <= 0 || y > 315 || y >= x || x > 1800 || z >= 1000 || z <= 100)	return printf("Wrong Data"), 0;
	if(z * 2 < x)	return printf("No"), 0;
	puts("Yes");
	times = (z >= x) ? 1 : 2;
	if(y + times * (int)(z * 0.33) >= 315)	printf("Great");
	else if(y + times * (int)(z * 0.5) >= 315)	printf("Eh..\nOK");
	else if(y + times * z >= 315)	printf("Oh..\nOh..\nYes , If he can get 5-star.");
	else	printf("No\nNo\nNo\n%d", y + (int)(times * z * 0.5));
	return 0;
} 
posted @ 2021-12-21 21:06  Eason_AC  阅读(33)  评论(0)    收藏  举报