您的位置:首页 > 其它

zoj 2592 Think Positive(YY)

2013-09-07 21:59 218 查看
题意:把n个数(+1 或-1)放在一个圈上,问你有几个j 满足求和一圈前缀和 > 1

解题思路:个数就是n个数的和,这个优美的结论大家自己证明。。。

解题代码:

// File Name: f.c
// Author: darkdream
// Created Time: 2013年09月07日 星期六 14时28分49秒

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define LL long long
#define maxn 200005
//freopen("/home/plac/problem/input.txt","r",stdin);
//freopen("/home/plac/problem/output.txt","w",stdout);

int a[maxn];
int main(){
int t;
scanf("%d",&t);
while(t--)
{
int n;
int sum = 0 ;
scanf("%d",&n);
while(n--)
{
int temp ;
scanf("%d",&temp);
sum += temp;
}
if(sum > 0 )
printf("%d\n",sum);
else printf("0\n");
}

return 0 ;
}


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