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 zcxiao at 2006-07-07 11:42:39 on Problem 2291
#include <iostream>
using namespace std;
int main()
{
	int n,m,i,temp,j,weight;
	cin>>n;
	while(n-->0)
	{
		cin>>m;
		weight  = 0;
		int *W = new int[m];
		for(i=0;i<m;i++)
			cin>>W[i];
		for(i=0;i<m-1;i++)
			for( j=1;j<m;j++)
				if(W[j]>W[i])
				{
					temp = W[j];
					W[j] = W[i];
					W[i] = temp;				
				}
        
		for(j=m*W[0];;j--)
		{
			for(i=0;i<m;i++) 
			{
				if(double(j)/double(m-i) > W[m-i-1])
					continue;
				else 
				{
					weight = 1;
					cout<<j<<endl;
					break;
				}			
			}	
			if(weight)
					break;
		}
		delete[]W;			 
	}
	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