只用判断100以内的范围,因为1-100内的质数也少于1/3.
#pragma warning (disable:4996)
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <vector>
#include <set>
using namespace std;
bool divide(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0)
return false;
}
return true;
}
//void Prime() {
// for (int i = 2; i <= 1e3; i++) {
// if (is[i])
// continue;
// printf("%d ", i);
// for (int j = 2; i * j <= 1e3; j++)
// is[i * j] = 1;
// }
//}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int l, r;
scanf("%d%d", &l, &r);
if (r - l + 1 > 100) {
printf("Yes\n");
continue;
}
int cnt = 0;
for (int i = l; i <= r; i++) {
if (divide(i)) {
cnt++;
}
}
if (3 * cnt < r - l + 1)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}