题目传送门
题目大意
有顾客想购买x
(
l
<
=
x
<
=
r
)
(l<=x<=r)
(l<=x<=r)包猫粮,你可以选择a包猫粮并且将其打包,顾客会首先买打包好的,而后剩余的
x
m
o
d
a
x\ mod\ a
x mod a包猫粮将会一包一包买,除非
x
m
o
d
a
≥
a
/
2
x\ mod\ a\ ≥\ a/2
x mod a ≥ a/2
你需要使得所有的顾客买的猫粮都高于想买的,即为
(
l
<
=
x
<
=
r
)
(l<=x<=r)
(l<=x<=r)上所有的顾客都满足
x
m
o
d
a
≥
a
/
2
x\ mod\ a\ ≥\ a/2
x mod a ≥ a/2
思路
很明显重要的条件是满足
x
m
o
d
a
≥
a
/
2
x\ mod\ a\ ≥\ a/2
x mod a ≥ a/2,即为使得等式左边大,右边小
x最大即为r,所有可以假设a=r+1,这样既可满足上述条件,再判断l是否满足即可
AC Code
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<math.h>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
// #define int long long
#define debug(a) cout<<#a<<"="<<a<<endl;
typedef long long ll;
const double PI=acos(-1.0);
const double e=exp(1.0);
const int M=1e9+7;
const int N=2e5+7;
inline int mymax(int x,int y){return x>y?x:y;}
inline int mymin(int x,int y){return x<y?x:y;}
int l, r, a;
void solve(){
cin>>l>>r;
a=r+1;
if(l%a >= (a+1)/2) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T;
cin>>T;
while(T--) solve();
return 0;
}