TOJ 1809.Playground(多角形条件を構成)


テーマリンク:http://acm.tju.edu.cn/toj/showp1809.html
1809.   
Playground
Time Limit: 1.0 Seconds   
メモリLimit: 65536 K
Total Runs: 3056   
Acceepted Runs: 770
George has K≦20 steel wires shaped in the form of half-circles、with radii a
1,a
2,…,a
K.The y can be solded at the ends、in any angle.Is it possible for George to make a closed shop of these wires?He does not have to use all the wires.
The Wires can be combined at any angle,but may not intersect.Beware of float point errors.
Input specification s
Each data set consists of a number 0<K≦20 on a line by itself、フォローアップby line of K space-separated numbers ai.Each number is in the range 0<ai < 107,and has at most 3 digits after the decimal point.The input will be terminated by a zero on a line by itself.
Output specification s
For each test case,there shound be one word on a line by itself:「YES」if it is possible to make a simple connected figure out of the given arcs,and「NO」if it isn't.
Sample Input
1
4.000
2
1.000 1.000
3
1.455 2.958 4.424
7
1.230 2.577 3.411 2.968 5.301 4.398 6.777
0
Sample Output
NO
YES
NO
YES
ソース: Nordic Colleggiat Conttest 2005
Submit   List    Runs   Forum   Statistics
多角形を構成する条件と同じです。半円に対しては、二つの半円が閉じられます。
#include 
#include 
using namespace std;
int main(){
	double wire[21];
	int n;
	while(~scanf("%d",&n),n){
		bool flag=false;
		for(int i=0;i