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

哪位大牛给看看哪的问题,一直是RTE!谢谢!

Posted by hbu06_194 at 2006-08-26 15:58:47 on Problem 2976
#include <iostream>
using namespace std;
typedef struct
{
	double a;
	double b;
}numNode;

int main()
{
	numNode num[1010];
	double res[1010],result,total,a,b;
	int t,k,i,j,max;
	cin>>t>>k;
	while(t||k)
	{
		for(i=0;i<t;i++)
			cin>>num[i].a;
        for(i=0;i<t;i++)
			cin>>num[i].b;
		for(i=0;i<t;i++)
			res[i]=0;
		total=0;
		while(1)
		{
		   	for(i=0;i<t;i++)
			{
				a=0;
				b=0;
	    		for(j=0;j<t;j++)
				{
					if(j!=i)
					{
						a=a+num[j].a;
						b=b+num[j].b;
					}
				}
				if(b!=0)  res[i]=a/b;
				else res[i]=0;
			}
	    	max=0;
		    for(i=1;i<t;i++)
		     	if(res[i]>res[max])
		     		max=i;
	     	for(j=max;j<t;j++)
	     		num[j]=num[j+1];
	    	total++;
	    	t=t-total;
			if(total==k)
			{
				a=0;
				b=0;
				for(i=0;i<t;i++)
				{
					a=a+num[i].a;
					b=b+num[i].b;
				}
			    if(b!=0) result=a*100/b;
                else result=0;
				result=(int)result;
				cout<<result<<endl;
				break;
			}
		}
		cin>>t>>k;
	} 
	return 1;
}

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