B. Kana and Dragon Quest game 1337B
question meaning: given h, the upper limit of operation 1, 2 n, m.
- 操作1: h ⇒ ⌊ h 2 ⌋ + 10 h\Rightarrow\left \lfloor \frac{h}{2} \right \rfloor+10 h⇒⌊2h⌋+10
- Operation 2: h ⇒ h − 10 h\Rightarrow h-10h⇒h−10
Idea: The number that can be subtracted from operation 2 is fixed. For operation 1, when h ⩾ 20 h\geqslant20h⩾2 0 h When always decline. And the larger the h, the more the reduction.
Perform operation 1 first, then operation 2. Determine whether the final is less than or equal to 0.
int main(){
int t;
cin>>t;
LL x,n,m;
while(t--){
cin>>x>>n>>m;
while(x>=20&&n>0){
n--;
x=x/2+10;
}
while(m>0){
m--;
x-=10;
}
if(x<=0)puts2();
else puts3();
}
return 0;
}