//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