Polylops

Time limit1sMemory limit128 MB

Summary
Given the vertices of a simple polygon, count how many distinct lines reflect it exactly onto itself.
Level

Medium7 of 10

Topics
Geometry, String matching, Implementation
Solved
No attempts yet

Problem

You are given, in order, the vertices of a non-degenerate simple polygon (no 180-degree angles, no zero-length sides, and no self-intersections — but not necessarily convex). Determine how many distinct lines of symmetry the polygon has.

A line of symmetry is a line such that reflecting the polygon across it maps the polygon exactly onto itself.

Input

The input consists of the descriptions of several polygons.

Each polygon is described by two lines. The first line contains the integer nn (3≤n≤10003 \le n \le 1000), the number of vertices of the polygon. The second line contains nn coordinate pairs (an xx value and a yy value each) giving the vertices of the polygon in order. All coordinates are integers between −1000-1000 and 10001000.

The input terminates with a polygon that has 00 vertices.

Output

For each polygon, print one line in the format Polygon #x has y symmetry line(s)., where xx is the number of the polygon (starting from 1) and yy is the number of distinct lines of symmetry of that polygon.

Examples2

  1. Example 1

    Input
    4
    -1 0 0 2 1 0 0 -1
    3
    -666 -42 57 -84 19 282
    3
    -241 -50 307 43 -334 498
    0
    
    Expected output
    Polygon #1 has 1 symmetry line(s).
    Polygon #2 has 0 symmetry line(s).
    Polygon #3 has 1 symmetry line(s).
    
  2. Example 2

    Input
    4
    0 0 4 0 4 4 0 4
    0
    
    Expected output
    Polygon #1 has 4 symmetry line(s).