UVa 412 - Pi

412 - Pi

 * http://acm.uva.es/p/v4/412.html (Submission page: http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=353)

Also seen:
 * http://acm.tju.edu.cn/toj/showp1100.html

Summary
Given a list of integers, determine the value of pi using the ratio of pairs without a common factor other than 1, and the total number of pairs.

Explanation
Given a large collection of integers, the probability of finding a pair of numbers that have no common factors other than 1 is approximatly 6/pi^2.

After counting the number of pairs of numbers, you can use basic algebra to determine the value of pi. However, there are some number sets that do not have pairs without common factors, which would result in a division by zero.

Gotchas

 * 1 doesn't share common factors greater than 1 with any other number.

Input
5 2 3 4 5 6 2 13 39 0

Output
3.162278 No estimate for this data set.