3187666 | LKY | 1011 | Accepted | 184K | 62MS | C++ | 918B | 2008-03-18 16:04:03 |
#include <algorithm>
using namespace std;
int stick[100], n;
bool used[100];
bool comp(int &a, int &b)
{
return a > b;
}
bool dfs(int unused, int left, int len)
{
if(unused == 0 && left == 0)
return true;
int i;
if(left == 0) left = len;
for (i=0; i<n; ++i)
{
if(!used[i] && stick[i]<=left)
{
used[i] = true;
if(dfs(unused-1, left-stick[i], len))
return true;
used[i] = false;
if(stick[i] == left || left == len)
break;
}
}
return false;
}
int main()
{
int i, sum;
while (scanf("%d", &n) != EOF && n)
{
sum = 0;
for (i=0; i<n; ++i)
{
scanf("%d", &stick[i]);
used[i] = false;
sum += stick[i];
}
sort(stick, stick+n, comp);
for (i=stick[0]; i<=sum; ++i)
{
if(sum % i == 0)
{
if(dfs(n, 0, i))
{
printf("%d/n", i);
break;
}
}
}
}
return 0;
}