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

你开这么大数组,系统当然开不了啊,你自己酸酸需要多少内存给你开

Posted by hawk at 2004-02-14 11:03:29 on Problem 1491
In Reply To:why system error??? Posted by:fdfzq at 2004-02-14 10:46:11
> include<iostream.h>
> #include<math.h>
> #include<iomanip.h>
> int answer[32768][32767];
> int gcd(int aa,int bb)
> {
> 	if(bb==0)
> 	{
> 		answer[aa][bb]=aa;
> 	}
> 	else
> 	{
> 		if(answer[bb][aa%bb]!=0)
> 			answer[aa][bb]=answer[bb][aa%bb];
> 		else
> 		{
> 			answer[bb][aa%bb]=gcd(bb,aa%bb);
> 			answer[aa][bb]=answer[bb][aa%bb];
> 		}
> 	}
> 	return answer[aa][bb];
> }
> void main()
> {
> 	
> 	int n,i,j;
> 	double m;
> 	int a[51];
> 	
> 	while(cin>>n)
> 	{
> 		if(n==0)
> 			return;
> 		else
> 		{
>             int num=0;
> 			for(i=1;i<=n;i++)
> 				cin>>a[i];
> 			for(i=1;i<=n;i++)
> 				for(j=i+1;j<=n;j++)
> 				{
> 					if(a[i]>a[j])
> 					{
> 						if(gcd(a[i],a[j])==1)
> 						num++;
> 					}
> 					if(a[i]<a[j])
> 					{
> 						if(gcd(a[j],a[i])==1)
> 							num++;
> 					}
> 					if((a[i]==1)&&(a[j]==1))
> 						num++;
> 				}
> 					if(num==0)
> 					{
> 						cout<<"No estimate for this data set."<<endl;
> 						
> 					}
> 					else
> 					{
> 						m=sqrt(3.0*n*(n-1)/num);
> 						cout<<setiosflags(ios::fixed);
> 						cout<<m<<setprecision(6)<<endl;
> 						
> 					}
> 		}
> 	}
> }

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