poj 1491 Pi

poj 1491 Pi,第1张

poj 1491 Pi
#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <cmath>using namespace std;#define maxn 55int n;int f[maxn];int gcd(int a, int b){    if (b > 0)        return gcd(b, a % b);    return a;}void input(){    for (int i = 0; i < n; i++)        scanf("%d", &f[i]);}void work(){    int numerator = 0;    for (int i = 0; i < n; i++)        for (int j = i + 1; j < n; j++) if (gcd(f[i], f[j]) == 1)     numerator++;    if (numerator == 0)    {        printf("No estimate for this data set.n");        return;    }    printf("%.6fn", sqrt(n * (n - 1) * 3.0 / numerator));}int main(){    while (scanf("%d", &n), n)    {        input();        work();    }    return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4904761.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存