
4950 | Monster |
MonsterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description
Teacher Mai has a kingdom. A monster has invaded this
kingdom, and Teacher Mai wants to kill it. Monster initially has h HP. Teacher Mai and monster take turns After k consecutive round's attack, Output "YES" if Teacher Mai can kill this monster, Input
There are multiple test cases, terminated by a line "0
0 0 0". For each test case, the first line contains four integers Output
For each case, output "Case #k: " first, where k is the
case number counting from 1. Then output "YES" if Teacher Mai can kill this monster, else output "NO". Sample Input
5 3 2 2
0 0 0 0 Sample Output
Case #1: NO
Source
Recommend
hujie
|
2014多校8 第六题 1006
大意:主角打boss,boss有h血,每回合主角打a血,然后boss回b血。主角打k回合后需要休息1回合,boss也回血。问主角能否打死boss。
题解:
惊天大水题。不过一开始一大堆人wa,我还怕了好久。认真分析,其实是很容易1A的。
我们分3种情况:
1.一刀砍死:
h-a < 1
2.连砍k刀将其砍死:
h-(a-b)*(k-1)-a < 1
3.连砍k刀之后休息一回合,怪的血量减少
h-(a-b)*(k)+b < h
这三种情况就是全部了,其中任意一个为true,就能砍死怪。
题目说可以在没砍到k刀就停下来休息,其实是不优的,要不就一刀砍死,要不就连砍k刀再休息,要是砍不到k刀就休息还能削弱怪物的血,连砍k刀肯定更能削弱怪物的血,这个情况归类到情况3中。
实在是太水了,居然只问yes和no,至少也问一下多少回合砍死啊!
代码:
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usint unsigned int
#define mz(array) memset(array, 0, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("1biao.out","w",stdout) int main() {
int cas=, ans;
ll h,a,b,k;
while(scanf("%I64d%I64d%I64d%I64d",&h,&a,&b,&k)!=EOF) {
if(h== && a== && b== && k==)break;
if(h-a<)ans=;
else if(h-(a-b)*(k-)-a<)ans=;
else {
if(h-(a-b)*(k)+b>=h)ans=;
else ans=;
}
if(ans==)printf("Case #%d: NO\n",cas++);
else printf("Case #%d: YES\n",cas++);
}
return ;
}