您的位置:首页 > 其它

poj 1247 Magnificent Meatballs

2011-07-17 23:55 399 查看
#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;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: