View Code of Problem 6

#include<iostream>
#include <string>
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;
    cin>>T;
    while(T>0) {
        int n;
        int min,max;
        cin >> n;
        if (n < 2) {
        cout << "YES" << endl;
        goto kk;
        }
        Trap trap[n];
        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;
        for(int i=min;i<=max;i++) {
            for (int j = 0; j < n; j++) {
                for (int k = i; k < 50001; k += i) {
                    if (trap[j].isInto(k)) {
                        cout << "NO" << endl;
                        goto kk;
                    }
                }
            }
        }
        cout<<"YES"<<endl;
        kk:T--;
    }

    return 0;
}
/*
Main.cc: In function 'int main()':
Main.cc:46:9: error: jump to label 'kk' [-fpermissive]
         kk:T--;
         ^~
Main.cc:24:14: note:   from here
         goto kk;
              ^~
Main.cc:26:14: note:   crosses initialization of 'Trap trap [n]'
         Trap trap[n];
              ^~~~
*/

Double click to view unformatted code.


Back to problem 6