1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 412 Pi
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=6&problem=353&mosmsg=Submission+received+with+ID+7516074
*
* @author Stefan Gohlke
* @version 1.0, 10/28/2009
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.2880
*/

package pi_acc;

import java.util.Scanner;
import java.text.DecimalFormat;

public class Main {

public static void main (String[] args)
{
pi();
}

public static void pi()
{
Scanner scanner = new Scanner(System.in);

int n = scanner.nextInt();

while (n > 1 && n < 50)
{
int[] zahlen = new int[n];
int N = (n * (n - 1)) / 2;

for (int i=0; i < n; i++)
{
zahlen[i] = scanner.nextInt();
}

int P = 0;

for (int i=0; i < n-1;i++)
{
for (int j = i+1; j < n; j++)
{
if (gcd(zahlen[i], zahlen[j]) == 1) P++;
}
}

if (P==0)
{
System.out.println("No estimate for this data set.");
}
else
{
double Pi = Math.sqrt((6 * N) / (double)P);
DecimalFormat df = new DecimalFormat("0.000000");
System.out.println(df.format(Pi).replace(',', '.'));
}

n = scanner.nextInt();
}
}

public static int gcd(int a, int b) {

int x = 0;
int lastx = 1;
int y = 1;
int lasty = 0;
int quotient;
int temp;

while (b != 0)
{
quotient = a / b;
temp = b;
b = a % b;
a = temp;

temp = x;
x = lastx-quotient*x;
lastx = temp;

temp = y;
y = lasty-quotient*y;
lasty = temp;
}

return a;
}
}