###### TOJ 4112 Counting problem

Simple problem;

The work you should do is  calculate the sum of prefix;

The portal:http://acm.tju.edu.cn/toj/showp4112.html

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

int sum[200005];

void Deal_with(){
int T;
scanf("%d",&T);
while(T--){
sum[0] = 0;
int n,temp;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&temp);
sum[i] = sum[i-1] + temp;
//printf("%d\n",sum[i]);
}
int C;
scanf("%d",&C);
int cnt = 0,i = 0,j = 1;
while(i<=n){
if(sum[j] - sum[i] == C){
cnt ++;
j ++ ; i ++ ;
if(j > n) break;
}
else if(sum[j] - sum[i] < C){
j ++;
if(j > n) break;
}
else {
i ++;
}
}
printf("%d\n",cnt);
}
}

int main(void){
//freopen("a.in","r",stdin);
Deal_with();
return 0;
}


#### TOJ 3349 Counting Divisor / 素数筛选法

2013-10-23 20:15:57

#### POJ 2282 The Counting Problem，组合数学

2014-06-04 10:34:01

#### Kickstart Round A 2017 Problem A. Square Counting Problem B. Patterns Overlap

2017-03-05 22:07:04

#### Problem 19 Counting Sundays （计算星期天）

2016-10-27 21:55:19

#### Kickstart Round A 2017 Problem A. Square Counting 公式、数论逆元、除法取模

2017-03-06 19:57:06

#### Counting Inversions 统计逆序数算法

2013-02-28 17:13:39

#### 山东省第四届ACM大学生程序设计竞赛 Boring Counting 划分树

2016-04-12 19:03:30

#### 富士施乐4112 驱动

2015年04月12日 10.6MB 下载

#### TOJ 1001

2017-11-26 11:19:26

#### fjnu 1195 Making Change

2008-03-07 12:45:00

## 不良信息举报

TOJ 4112 Counting problem