Normalized vectors X96647


Statement
 

pdf   zip

A vector of points on the plane is normalized if all the following three conditions hold:

  1. The vector contains at least two different elements.

  2. The sum of all the xx-coordinates of the points in the vector equals the sum of all the yy-coordinates of the points in the vector.

  3. The barycenter of the points in the vector does not belong to the vector.

Recall that the barycenter of a set of points is the point (x,y)(x,y) of the plane which has the average value of the xx-coordinates of the points as xx-coordinate, and the average value of the yy-coordinates of the points as yy-coordinate.

 
Make a program that reads vectors of points on the plane and determines whether they are normalized or not.

Your program must use the following definition:

struct Point {\{

double x,y;

}\};

and it must also define, implement and use the following function:

bool barycenter (const vector<<Point>>& v, Point& b);

which, given a vector of points vv, it computes in bb the barycenter of the points in vv and returns a boolean indicating whether bb is to be found in vv or not.

Input

The input consists in several lines with sequences. Each sequence describes a vector of points by means of a natural number n>0n>0, which is followed by nn pairs of real numbers x1x_1, y1y_1, \ldots, xnx_n, yny_n describing the coordinates of the nn points in the vector.

Output

For each vector of points, the output indicates the barycenter of its points and whether the vector is a normalized one or not. In case the vector is not normalized, the output indicates which of the three required properties of the definition is the first one not holding.

 
You are asked to follow the output format of the examples.

 

Real numbers must be written using 2 digits in their fractional part. Use:

cout.setf(ios::fixed);

cout.precision(2);

Public test cases
  • Input

    3 0 0 0 0 0 0
    4 1 0 1 1 1 0 1 0
    3 0 1 0 -1 0 0
    3 0 1 1 0 1 1
    4 0 0 1 0 0 1 0 0
    3 0 0 1 1 0 0
    

    Output

    barycenter: (0.00,0.00)
    property 1 does not hold
    barycenter: (1.00,0.25)
    property 2 does not hold
    barycenter: (0.00,0.00)
    property 3 does not hold
    barycenter: (0.67,0.67)
    normalized vector
    barycenter: (0.25,0.25)
    normalized vector
    barycenter: (0.33,0.33)
    normalized vector
    
  • Information
    Author
    Maria J. Serna i Maria J. Blesa
    Language
    English
    Translator
    Maria J. Blesa
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    Unknown.
    User solutions
    C++