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 syqqscu at 2009-05-08 13:01:33 on Problem 1011
帮忙检查下程序,样例都通过了

#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() 
{
	int count;
	int i, num,max;
	int sum;
	typedef map< int, int, less<int> > mid;
	mid pairs;
	vector<int> vc;

	while( (cin >> count) && (count != 0) )
	{
		sum = 0;
		cin >> num;
		max = num;
		sum += num;
		
		for (i=1; i<count; i++)
		{
			cin >> num;
			if(num > max)
			{
				max = num;
			}
			sum += num;
		}

		for (i=1; i<=(sum/max); i++)
		{
			if(sum % i == 0)
			{
				pairs.insert(mid::value_type(sum/i,i));
			}
		}
		
		mid::const_iterator iter = pairs.begin();
		vc.push_back(iter->first);
	}
	
	for (i=0; i<vc.size(); i++)
	{
		cout << vc[i] << 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