Shrinking Polygons hust 14048
来源:互联网 发布:c语言删除文件函数 编辑:程序博客网 时间:2024/05/17 04:45
[Submit] [Go Back] [Status]
Description
A polygon is said to be inscribed in a circle when all its vertices lie on that circle. In this problem you will be given a polygon inscribed in a circle, and you must determine the minimum number of vertices that should be removed to transform the given polygon into a regular polygon, i.e., a polygon that is equiangular (all angles are congruent) and equilateral (all edges have the same length).
When you remove a vertex v from a polygon you first remove the vertex and the edges connecting it to its adjacent vertices w1 and w2, and then create a new edge connecting w1 and w2. Figure (a) below illustrates a polygon inscribed in a circle, with ten vertices, and figure (b) shows a pentagon (regular polygon with five edges) formed by removing five vertices from the polygon in (a).
In this problem, we consider that any polygon must have at least three edges.
Input
The input contains several test cases. The first line of a test case contains one integer N indicating the number of vertices of the inscribed polygon (3 ≤ N ≤ 104). The second line contains N integers Xi separated by single spaces (1 ≤ Xi ≤ 103, for 0 ≤ i ≤ N -1). Each Xi represents the length of the arc defined in the inscribing circle, clockwise, by vertex i and vertex (i+1) mod N. Remember that an arc is a segment of the circumference of a circle; do not mistake it for a chord, which is a line segment whose endpoints both lie on a circle.The end of input is indicated by a line containing only one zero.
Output
For each test case in the input, your program must print a single line, containing the minimum number of vertices that must be removed from the given polygon to form a regular polygon. If it is not possible to form a regular polygon, the line must contain only the value -1.
Sample input31000 1000 100061 2 3 1 2 331 1 21010 40 20 30 30 10 10 50 24 260Output for the sample input
02-15
ACM ICPC :: South American Regional 2008
Source
- Shrinking Polygons hust 14048
- Polygons
- HUST
- HUST
- HUST
- HUST
- weblogic Shrinking
- Shrinking Segments
- On shrinking table sizes
- Shrinking Database Segments Online
- Shrinking Virtual Disks of VMWare
- UVA 10005 Packing polygons
- UVA 137 Polygons
- Codeforces 166B - Polygons
- uva10005(Packing polygons)
- [UVA10005]Packing polygons
- UVa 10005 - Packing polygons
- codeforces 166 B. Polygons
- md5sum
- B/S与C/S的介绍与比较
- 倒排文件索引结构
- ISAP算法 POJ_3469
- tomcat运行
- Shrinking Polygons hust 14048
- 心情又开始浮躁了
- Touchlib简介
- JS实现动态图片新闻
- 如何成为Android高手
- Linux系统调用列表
- Gearman分布式远程过程处理框架
- ubuntu下google-chrome更新问题
- 在Ubuntu10.04上安装qt4.7