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 cyber_shoot at 2008-07-29 13:34:21 on Problem 3300
#include<iostream>
#include<iomanip>
using namespace std;
#include<stdlib.h>
int cmp(const void*x,const void*y)
{
	return *(float*)x-*(float*)y;
}
int main()
{
	int front,rear,snum;
	while(cin>>front&&front!=0)
	{
		cin>>rear;
		int*f,*r;
		f=new int[front];
		r=new int[rear];
		int i,j;
		for(i=0;i<front;i++)
			cin>>f[i];
		for(i=0;i<rear;i++)
			cin>>r[i];


		float*a,*b;
		snum=front*rear;
		a=new float[snum];
		b=new float[snum-1];
		for(i=0;i<front;i++)
			for(j=0;j<rear;j++)
				a[rear*i+j]=r[j]*1.0/f[i];
		qsort(a,snum,sizeof(float),cmp);
		for(i=0;i<snum-1;i++)
			b[i]=a[i+1]/a[i];
		float max=0;
		for(i=0;i<snum-1;i++)
			if(b[i]>max)
				max=b[i];
		cout<<setprecision(2)<<setiosflags(ios::fixed)<<max<<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