poj 1247 Magnificent Meatballs

#include <iostream>
using namespace std;
int main()
{
int n,list[31],total,i;
while(cin>>n&&n)
{
total
=0;
for( i=1;i<=n;i++)
{
cin
>>list[i];
total
+=list[i];
}
if(total%2!=0)
cout
<<"No equal partitioning.\n";
else
{
total
/=2;
int sum=0;
for( i=1;;i++)
{
sum
+=list[i];
if(sum>=total)
break;
}
if(sum==total)
cout
<<"Sam stops at position "<<i<<" and Ella stops at position "<<i+1<<".\n";
else
cout
<<"No equal partitioning.\n";
}
}
return 0;
}

  

posted on 2011-07-17 23:55  sysu_mjc  阅读(84)  评论(0编辑  收藏  举报

导航