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

1011 我不知道错在哪里了,哪位大牛帮我看一下

Posted by xinjie2009 at 2009-05-18 23:12:08 on Problem 1011
#include <iostream>
using namespace std;
int main()
{
	int t,i;
	int max,sum,temp;
	do
	{
		cin >> t;
		if (t == 0)  break;
		max = 0;
		sum = 0;
		for (i = 0; i < t;++i)
		{
			cin >> temp; 
			max = temp > max ? temp : max;
			sum += temp;
		}
		for (i = sum; i > 0;--i)
		{
			if (sum % i  == 0 && sum / i > max)
			{
				cout << sum / i << endl;
				break;
			}
		}
	}while (t != 0);
	return 0;
}
我是用max记录木棍的最大值,因为原先的木棍是等长的,所以只要找出所有木棍的总长sum的一个最小的但比截得后的最长木棍max大的一个因子就可以了。可是这样做还是WA,请哪位大侠指点一下,谢谢啦!!

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