#include <stdio.h> int main(){ int T; scanf("%d", &T); while(T--){ int n; int a[100], b[100]; scanf("%d", &n); for(int j = 0; j < n; j++) scanf("%d%d", &a[j], &b[j]); int step = b[0]; while(step <= a[1]){ int flag = 1, i = step, j; for(j = 1; j < n - 1; j++){ i += step; if(i < b[j] || i > a[j + 1]){ flag = 0; break; } } if(i + step < b[j]) flag = 0; if(flag){ printf("YES\n"); break; } else step++; } if(step > a[1]) printf("NO\n"); } return 0; } |
Double click to view unformatted code.