# 天仙配

``````3
3 6 2 4 5 2
0``````

``2``

``````#include <stdio.h>
int main()
{
int n, i, j, count, a[20000];
int sum_nan, sum_nv;

while (scanf("%d", &n) != EOF && n != 0)
{
count = sum_nan = sum_nv = 0;
for (i = 0; i < 2 * n; i++)
{
scanf("%d", &a[i]);
sum_nan += a[i];
}
sum_nv = sum_nan;

for (j = 2 * n - 1, i = 0; i < 2 * n && j >= 0;)
{
if (sum_nan == sum_nv)
{
sum_nan -= a[j--];
sum_nv -= a[i++];
count++;
}
else if (sum_nan > sum_nv)
{
sum_nan -= a[j--];
}
else if (sum_nan < sum_nv)
{
sum_nv -= a[i++];
}

}
printf("%d\n", count);
}
return 0;
}``````

``````#include <stdio.h>
int main()
{
int n, i, j, count, a[20000];
int sum_nan, sum_nv;

while(scanf("%d",&n)!=EOF&&n!=0)
{
count=sum_nan=sum_nv=0;
for(i=0;i<2*n;i++)
{
scanf("%d", &a[i]);
sum_nan+=a[i];
}
sum_nv=sum_nan;
for(j=2*n-1,i=0;i<2*n&&j>=0;)
{
if (sum_nan==sum_nv)
{
sum_nan-=a[j--];
sum_nv-=a[i++];
count++;
}
else if(sum_nan>sum_nv)
{
sum_nan-=a[j--];
}
else if(sum_nan<sum_nv)
{
sum_nv-=a[i++];
}

}
printf("%d\n",count);
}
return 0;
}``````