#include<iostream> using namespace std; class Trap { public: int head; int tail; bool isInto(int &a) { if (a > head && a < tail) return 1; else return 0; } }; int main() { int T,i; cin >> T; while (T > 0) { int n; int min, max; cin >> n; Trap trap[n]; if (n < 2) { cout << "YES" << endl; goto kk; } for (int i = 0; i < n; i++) { int h, t; cin >> h >> t; trap[i].head = h; trap[i].tail = t; } min = trap[0].tail; max = trap[1].head; i = min; mm: for (; i <= max; i++) { for (int k = i; k < 50001; k += i) { for (int j = 0; j < n; j++) { if (trap[j].isInto(k)) { i++; goto mm; } } } cout << "YES" << endl; goto kk; } cout<<"NO"<<endl; kk: T--; } return 0; } |
Double click to view unformatted code.