zoj 2592 Think Positive(YY)

题意:把n个数(+1 或-1)放在一个圈上,问你有几个j 满足求和一圈前缀和 > 1

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

解题代码:

 1 // File Name: f.c
 2 // Author: darkdream
 3 // Created Time: 2013年09月07日 星期六 14时28分49秒
 4 
 5 #include<stdio.h>
 6 #include<string.h>
 7 #include<stdlib.h>
 8 #include<time.h>
 9 #include<math.h>
10 #define LL long long
11 #define maxn 200005
12 //freopen("/home/plac/problem/input.txt","r",stdin);
13 //freopen("/home/plac/problem/output.txt","w",stdout);
14 
15 int a[maxn];
16 int main(){
17    int t; 
18    scanf("%d",&t);
19    while(t--)
20    {
21      int n;
22      int sum = 0 ;
23      scanf("%d",&n);
24      while(n--)
25      {
26        int temp ;
27        scanf("%d",&temp);
28        sum += temp; 
29      }
30     if(sum > 0 )
31         printf("%d
",sum);
32     else printf("0
");
33    }
34 
35 return 0 ;
36 }
View Code
没有梦想,何谈远方
原文地址:https://www.cnblogs.com/zyue/p/3307831.html