⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 412 pi.cpp

📁 UVA Online Judge solutions to the problems
💻 CPP
字号:
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int gcd(int a,int b)
{
     int x,z;
     if(b==0)
     return a;
     x=a%b;
     z=gcd(b,x);
     return z;
}
int main()
{
    int n,i,j;
    int arr[60];
    float ans;
    while(cin>>n && n!=0)
    {
                 for(i=0;i<n;i++)
                 cin>>arr[i];
                 
                 int deno=n*(n-1)/2;
                 int num=0;
                 for(i=1;i<n;i++)
                 {
                         for(j=0;j<i;j++)
                         {
                                         if(gcd(arr[i],arr[j])==1) 
                                         num++;
                                         else
                                         continue;
                         }
                 }
                 
                
                 if(num!=0)
                 {
                  float mul=(deno*6)/(float)num;
                  ans=sqrt(mul);
                  printf("%.6lf\n",ans);
                  }
                 else
                 cout<<"No estimate for this data set."<<endl;
    }
    system("pause");
}
                  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -