Hdu5323solve This interesting problem

Source: Internet
Author: User

//Give a logarithm [l,r]//Ask to find the minimum n so that the left and right range of the root node of the segment tree is [0,n], and//The node in the segment tree has a left and right range of [L,r]//due to l/(r-l+1) ≤2015//Can be directly violent search for the case of its Father node with [L,r] as a node//And compare its minimum value#include <iostream>#include <cstring>#include <cstdio>using namespace STD;typedef Long Longll;Const__int64 inf =1e18; ll ans; ll L, R;voidDFS (ll L, ll R) {if(R >= ans)return;if(L <0)return;if(L = =0) {ans = R;return;}if(R-l +1> L)return; Dfs2* (L-1)-R, R); Dfs2* (L-1)-R +1, R); DFS (L,2*R-L); DFS (L,2*r-l +1) ;}intMain () {ll L, R; while(~scanf("%i64d%i64d", &l, &r)) {ans = inf; DFS (L, R);if(ans = = inf)puts("-1");Else        printf("%i64d\n", ans); }}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hdu5323solve This interesting problem

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.