hdu4950 Monster (水题)
4950 | Monster |
MonsterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 52 Accepted Submission(s): 29 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. And it will die if HP is less than 1. Teacher Mai and monster take turns to do their action. In one round, Teacher Mai can attack the monster so that the HP of the monster will be reduced by a. At the end of this round, the HP of monster will be increased by b. After k consecutive round's attack, Teacher Mai must take a rest in this round. However, he can also choose to take a rest in any round. Output "YES" if Teacher Mai can kill this monster, else output "NO". Input
There are multiple test cases, terminated by a line "0
0 0 0".
For each test case, the first line contains four integers h,a,b,k(1<=h,a,b,k <=10^9). 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,至少也问一下多少回合砍死啊!
代码:
1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 #include<cstdio> 3 #include<cmath> 4 #include<iostream> 5 #include<cstring> 6 #include<algorithm> 7 #include<cmath> 8 #include<map> 9 #include<set> 10 #include<stack> 11 #include<queue> 12 using namespace std; 13 #define ll long long 14 #define usint unsigned int 15 #define mz(array) memset(array, 0, sizeof(array)) 16 #define minf(array) memset(array, 0x3f, sizeof(array)) 17 #define REP(i,n) for(i=0;i<(n);i++) 18 #define FOR(i,x,n) for(i=(x);i<=(n);i++) 19 #define RD(x) scanf("%d",&x) 20 #define RD2(x,y) scanf("%d%d",&x,&y) 21 #define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z) 22 #define WN(x) printf("%d\n",x); 23 #define RE freopen("D.in","r",stdin) 24 #define WE freopen("1biao.out","w",stdout) 25 26 int main() { 27 int cas=1, ans; 28 ll h,a,b,k; 29 while(scanf("%I64d%I64d%I64d%I64d",&h,&a,&b,&k)!=EOF) { 30 if(h==0 && a==0 && b==0 && k==0)break; 31 if(h-a<1)ans=1; 32 else if(h-(a-b)*(k-1)-a<1)ans=1; 33 else { 34 if(h-(a-b)*(k)+b>=h)ans=0; 35 else ans=1; 36 } 37 if(ans==0)printf("Case #%d: NO\n",cas++); 38 else printf("Case #%d: YES\n",cas++); 39 } 40 return 0; 41 }