/**
 * Tools useful for generating tests to HeadAndShoulders problem.
 */

#ifndef __TOOLS_H__
#define __TOOLS_H__

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>

#include <algorithm>
#include <vector>
#include <set>

using std::random_shuffle;
using std::vector;
using std::set;

int random() {
    return rand() + (rand() << 16);
}

struct Hair {
    double xh, yh, xs, ys;

    void print() {
        printf("%0.15f %0.15f %0.15f %0.15f\n", xh, yh, xs, ys);
    }
};

const double PI = 3.1415926535897932384626433832795;

/**
 * Returns a bound for the given (x,y) point on head and y = -k point on shoulders.
 * A bound is such a number that (x,y) - (bound,-k) is a touch line to the head circle.
 *
 * For positive x, any x_s >= bound is permitted. 
 * For negative x, any x_s <= bound is permitted.
 * For x = 0, any x_s is permitted.
 */
inline double getBound(double x, double y, double k) {
    if (x == 0) return 0;
    return x + y * (k + y) / x;
}

#endif