HDU 5802 Windows 10

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.