Official:
Windows 10
_ You may be the victim of genuine Windows 10 _ just greedy.
The more intuitive view is to drop hard and then rise back
or push it down and then stop and then push down ...
So you can turn the problem into a sub-problem, and then DFS is fine.
It is important to note that a continuous downward effect can be interrupted by pressing the UP key.
So it should be recorded a few pauses, and later up with a pause to fill back
/* by*/#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<cmath>using namespaceStd;typedefLong LongLL;ConstLL n= -;ConstLL inf=0x3f3f3f3f; LL p,q;intMain () {LL T; CIN>>T; while(t--) {scanf ("%lld%lld",&p,&q); if(p<=q) {printf ("%lld\n", Q-p); Continue; } LL ans=inf,down=1, s=0, st=0;/*S: number of operations; ST: number of pauses*/ while(p>=q) {P-=Down ; down<<=1; S++; if(p<=q) { if(q-p<=st) {/*the number of up operations can be replaced by the number of pauses*/ans=min (ans,s+St); Break; } LL tmp=max (Q-max (p, LL)0), ST);/*volume greater than 0*/ans=min (ans,tmp+s); down>>=1; P+=Down ; down=1; St++; S--; }} printf ("%lld\n", ans); } return 0;}
HDU 5802 Windows 10