#include <iostream>
#include <cstdlib>
#include <math.h>
#include <cstring>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std ;
int gcd (int a ,int b)
{
if(a%b==0)
{
return b ;
}else
{
return gcd(b,a%b) ;
}
}
int main(void)
{
int x ;
while(cin>> x && x!=0)
{
int arr[100000] ;
for(int i=1;i<=x;i++)
{
cin >> arr[i];
}
int countp=0;
int countd=0;
for(int i=0 ;i<x;i++)
{
for(int j=i+1;j<x;j++)
{
countp++ ;
if(gcd(arr[i],arr[j])==1)
{
countd++ ;
}
}
}
if(countd==0)
{
cout << "No estimate for this data set." << endl ;
}else
{
double a = countp*6.0/ countd ;
double answer = sqrt(a) ;
answer = round(answer*1000000);
answer = answer/1000000;
cout << setprecision(7) << answer << endl;
}
}
return 0;
}
第 1 測資點(100%): WA(line:1) 答案不正確 您的答案為: 3.464102 正確答案為: 3.162278
想問一下是哪邊不對= =
#include
#include
#include
#include
#include
#include
#include
using namespace std ;
int gcd (int a ,int b)
{
if(a%b==0)
{
return b ;
}else
{
return gcd(b,a%b) ;
}
}
int main(void)
{
int x ;
while(cin>> x && x!=0)
{
int arr[100000] ;
for(int i=1;i<=x;i++)
{
cin >> arr[i];
}
int countp=0;
int countd=0;
for(int i=0 ;i {
for(int j=i+1;j {
countp++ ;
if(gcd(arr[i],arr[j])==1)
{
countd++ ;
}
}
}
if(countd==0)
{
cout << "No estimate for this data set." << endl ;
}else
{
double a = countp*6.0/ countd ;
double answer = sqrt(a) ;
answer = round(answer*1000000);
answer = answer/1000000;
cout << setprecision(7) << answer << endl;
}
}
return 0;
}
第 1 測資點(100%): WA(line:1) 答案不正確 您的答案為: 3.464102 正確答案為: 3.162278
想問一下是哪邊不對= =