Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

怎么AC不了呢?

Posted by sunnvya at 2006-09-22 09:16:53 on Problem 1491
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
using namespace std;
//int a[50];
inline bool com(int a,int b)
{
       int t;
       if(a<b){t=a;a=b;b=t;}
       while(b)
       {t=a%b;a=b;b=t;}
       if(a>1)return 1;
       else return 0;
}
int main()
{
    int n;
    while(cin>>n&&n)
    {
           //memset(a,0,50);
           int *a = new int[n];
	       for(int i=0;i<n;i++)
           cin>>a[i];
           int count=0;
           for(int i=0;i<n-1;i++) 
             for(int j=i+1;j<n;j++) 
                 if(!com(a[i],a[j]))count++;
           if(count==0)cout<<"No estimate for this data set."<<endl;
           else cout<<setiosflags(ios::fixed)<<setprecision(6)<<sqrt(3*n*(n-1)/count)<<endl;
           delete []a;   
              
    }
    
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator