1. 程式人生 > 實用技巧 >Http請求失敗,獲取返回狀態碼和訊息

Http請求失敗,獲取返回狀態碼和訊息

A. Marketing Scheme time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

You got a job as a marketer in a pet shop, and your current task is to boost sales of cat food. One of the strategies is to sell cans of food in packs with discounts.

Suppose you decided to sell packs withaacans in a pack with a discount and some customer wants to buyxxcans of cat food. Then he follows a greedy strategy:

  • he buysxa⌊xa⌋packs with a discount;
  • then he wants to buy the remaining(xmoda)(xmoda)cans one by one.

xa⌊xa⌋isxxdivided byaarounded down,xmodaxmodais the remainer ofxxdivided byaa.

But customers are greedy in general, so if the customer wants to buy(xmoda)(xmoda)cans one by one and it happens that

(xmoda)a2(xmoda)≥a2he decides to buy the whole pack ofaacans (instead of buying(xmoda)(xmoda)cans). It makes you, as a marketer, happy since the customer bought more than he wanted initially.

You know that each of the customers that come to your shop can buy any number of cans fromlltorrinclusive. Can you choose such size of pack

aathat each customer buys more cans than they wanted initially?

Input

The first line contains a single integertt(1t10001≤t≤1000)— the number of test cases.

The first and only line of each test case contains two integersllandrr(1lr1091≤l≤r≤109)— the range of the number of cans customers can buy.

Output

For each test case, printYESif you can choose such size of packaathat each customer buys more cans than they wanted initially. Otherwise, printNO.

You can print each character in any case.

Example input Copy
3
3 4
1 2
120 150
output Copy
YES
NO
YES
Note

In the first test case, you can take, for example,a=5a=5as the size of the pack. Then if a customer wants to buy33cans, he'll buy55instead (3mod5=33mod5=3,52=2.552=2.5). The one who wants44cans will also buy55cans.

In the second test case, there is no way to chooseaa.

In the third test case, you can take, for example,a=80a=80.

/*
這一題,要注意的一點是,L,和R他們之間的差是不會大於a/2的。
因為我們可以選取區間【L,R】內的任意一數,來作為我們要購買的商品數量,如果差值大於a/2,我們失去了賺錢的機會。
所以我們可以得到一個不等式
a/2 <= L%a <= R % a < a
現在我們要尋找的是邊界,是最大獲益的邊界,也就是讓a儘可能的大
我們發現,a最大值位L
讓L = a
又因為R - L < a / 2
所以,我們可以得到我們的公式
R-L < L / 2
整理公式得
R < 2 * L 
*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {
    int T; cin >> T;
    while (T -- ) {
        int l, r; cin >> l >> r;
        if (r < 2 * l) puts("YES");
        else puts("NO");
    }
    
    return 0;
}