| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator