Rezultati

Up. imeNalogaJezikRezultatČas oddaje
Muf Presek C++ 100/100OK 04. okt '18 @ 19:53

Test Točke Porabljen spomin Porabljen čas Status
#1 100/100 3,000 MiB 0,000 s OK

Ocenjevani program (presek.cpp):
#include <iostream>
#include <string>
using namespace std;


int pyt(int n, int m)
{
    return n*n+m*m;
}

int main()
{
    int n, left , bot , right , top , x , y , r;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> left >> bot >> right >> top >> x >> y >> r;
        // cin >> x1 >> y1 >> x2 >> y2 >> xk >> yk >> r;

        if (x >= left and x <= right and
            y >= bot  and y <= top) {
            cout << x << " " << y << endl;
        } else {
            if (y < top and y > bot) {
                if (x > right) {
                    if (x - right <= r) {
                        cout << right << " " << y << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                } else {
                    if (left - x <= r) {
                        cout << left << " " << y << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                }
            } else if (x < right and x > left){
                if (y > top) {
                    if (y - top <= r) {
                        cout << x << " " << top << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                } else {
                    if (bot - y <= r) {
                        cout << x << " " << bot << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                }
            } else {
                if (x >= right and y >= top) {
                    if (pyt(right - x, top - y) <= r*r) {
                        cout << right << " " << top << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                } else if (x >= right and y <= bot) {
                    if (pyt(right - x, y - bot) <= r*r) {
                        cout << right << " " << bot << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                } else if (x <= left and y >= top) {
                    if (pyt(left - x, top - y) <= r*r) {
                        cout << left << " " << top << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                } else {
                    if (pyt(left - x, bot - y) <= r*r) {
                        cout << left << " " << bot << endl;
                    } else {
                        cout << "Presek je prazen" << endl;
                    }
                }
            }
        }
    }
}