Codeforces Round 870 (Div. 2) C

89 阅读2分钟

C. Dreaming of Freedom

time limit per test

2.5 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Because to take away a man's freedom of choice, even his freedom to make the wrong choice, is to manipulate him as though he were a puppet and not a person.

— Madeleine L'Engle

There are n programmers choosing their favorite algorithm amongst m different choice options. Before the first round, all m options are available. In each round, every programmer makes a vote for one of the remaining algorithms. After the round, only the algorithms with the maximum number of votes remain. The voting process ends when there is only one option left. Determine whether the voting process can continue indefinitely or no matter how people vote, they will eventually choose a single option after some finite amount of rounds?

Input

The first line contains a single integer t (1≤t≤105) — the number of test cases.

Each test case consists of a single line containing two integers n and m (1≤n,m≤106) — the number of people and choice options respectively.

Output

For each test case output "YES" if the programmers will eventually choose a single option, and "NO" otherwise.

You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as a positive answer).

Example

input

Copy

5
3 2
4 2
5 3
1000000 1000000
1 1000000

output

Copy

YES
NO
YES
NO
YES

Note

In the first example, there are 88 ways people could vote: {1|1|1,1|1|2,1|2|1,1|2|2,2|1|1,2|1|2,2|2|1,2|2|2}

In cases 11, 22, 33, and 55, the programmers are left with the first algorithm, and in the remaining cases people are left with the second one, so the voting ends in one round in any case.

In the second example, the programmers could always vote 1|1|2|2 Both algorithms have the maximum number of votes and remain for the next round, so the voting never ends.

题意:让你不断的投票,票多的就进行下一轮继续投,一直到只剩一种方法或者找到一种投票方法让他可以一直投下去

思路:首先可以很清楚的知道n == 1或者m==1一定是YES然后如果m>=n一定是No因为我可以让每个人都有一种票,最后只有判断小于m的n的因子有没有就可以了

代码

// Problem: C. Dreaming of Freedom
// Contest: Codeforces - Codeforces Round 870 (Div. 2)
// URL: https://codeforces.com/contest/1826/problem/C
// Memory Limit: 256 MB
// Time Limit: 2500 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

using namespace std;
#define int long long 
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define YES puts("YES");
#define NO puts("NO");
#define Yes puts("Yes");
#define No puts("No");
#define fo(i,j,k) for(int i = j;i <= k;i ++)
#define pre(i,j,k) for(int i = j;i >= k;i --)
#define ls idx*2
#define rs idx*2+1
int pow_mod(int a1, int n1, int m1)
{
    if(n1 == 0) return 1;
    int x = pow_mod(a1, n1/2, m1);
    long long ans = (long long)x * x % m1;
    if(n1 % 2 == 1) ans = ans *a1 % m1;
    return (int)ans;
}
inline __int128 read(){
    __int128 x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if(ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
inline void print(__int128 x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9)
        print(x / 10);
    putchar(x % 10 + '0');
}
// bool operator<(NOW a, NOW b) {
	// if(a.site == b.site)
	// return a.x > b.x;
    // return a.site< b.site;
// }
const int N = 1e6 + 10;
int n,m;
bool p[N];
int pr[N];
void Euler() {
    int cnt = 0;
    memset(p, true, sizeof(p));
    p[0] = p[1] = false;    //特例
    for (int i = 2; i < N; ++i) {
        if (p[i]) pr[cnt++] = i;    //选出素数
        for (int j = 0; j < cnt && pr[j] * i < N; ++j) {
            p[pr[j] * i] = false;    //筛出非素数
            if (i % pr[j] == 0) break;    //重复筛选,跳出循环
        }
    }
}
void solve()
{
	cin >> n >> m;
	if(n == 1||m == 1)
	{
		YES;
		return;
	}
	if(n <= m)
	{
		NO;
		return;
	}
	for(int i = 2;i * i <= n;i ++)
	{
		if(n%i==0)
		{
			if(i<=m||n/i<=m)
			{
				NO;
				return;
			}
		}
	}
	YES;
}
signed main()
{
	//Euler();
	int tt = 1;
	sc(tt);
	while(tt--)
	{
		solve();
	}
}