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

为什么总是wa?帮助看一下吧!

Posted by novice at 2005-08-22 13:23:00 on Problem 1491
#include<iostream.h>
#include<stdio.h>
#include<math.h>
int main()
{
	long i,j,k,l,t,n,s;
	int a[110];
	double pi;
	while(cin>>n,n!=0)
	{
		k=0;s=0;
		for(i=0;i<100;i++)
			a[i]=0;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			if ((a[i]==1)||(a[i]==0)) {i--;n--;}
		}
		for(i=1;i<=n-1;i++)
			for(j=i+1;j<=n;j++)
			{
				t=1;
				for(l=2;l<=a[i];l++)
					if ((a[i]%l==0)&&(a[j]%l==0)) {t=l;break;}
				if (t==1) k++;
			}
		s=n*(n-1)/2;
		if (k!=0) {pi=sqrt(6*s/k);printf("%1.6lf\n",pi);}
		else cout<<"No estimate for this data set."<<endl;
	}
	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