题解 CF1337B 【Kana and Dragon Quest game】

ShineEternal

2020-04-16 11:15:08

Solution

[更佳护眼的阅读效果](https://blog.csdn.net/kkkksc03/article/details/105553446) ## description 一条龙的血量是 $x$,技能 $1$ 是使得 $x=[\dfrac{x}{2}]+10$,能使用 $n$ 次;技能 $2$ 使得 $x=x-10$,能使用 $m$ 次。给定 $x,n,m$,求出能不能使得 $x\le 0$。 ## solution 我们经过观察,发现大部分情况下使用技能 $1$ 的效果更好,但是如果 $x$ 和 $[\dfrac{n}{2}]$ 相差不超过 $10$ 时就会起到负作用。 所以我们可以首先使用技能 $1$ ,直到产生负作用或者使用完毕为止;然后使用技能 $2$ 。在这期间判断龙有没有被杀死就行了。 ## code ```cpp #include<cstdio> using namespace std; int main() { int T; scanf("%d",&T); while(T--) { int flag=0; int x,n,m; scanf("%d%d%d",&x,&n,&m); while(n--) { if(x-x/2<=10)break; x=x/2+10; if(x<=0) { printf("YES\n"); flag=1; break; } } while(m--) { x=x-10; if(x<=0) { printf("YES\n"); flag=1; break; } } if(flag==0) { printf("NO\n"); } } return 0; } ```