zoukankan      html  css  js  c++  java
  • 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
    没有梦想,何谈远方
  • 相关阅读:
    sql基础笔记备忘
    论坛---挂掉的思考
    http response
    跑步肋骨下方疼
    Golang
    svn rollback: 恢复到上一版本
    中国时区
    crontab
    初识redis
    siege
  • 原文地址:https://www.cnblogs.com/zyue/p/3307831.html
Copyright © 2011-2022 走看看