#d2868. 简单子段和

简单子段和

Simple Subarray Sum

Problem Description

You are given an integer array AA of length NN and an integer KK.

How many subarrays of AA have a sum exactly equal to KK?

Input Format

The first line contains two integers NN and KK: the size of array AA and the given integer KK.

The second line contains NN integers giving the elements A1,…,ANA_1, \dots, A_N of the array.

Output Format

Output one integer: the answer.

Sample Input 1

6 5
8 -3 5 7 0 -4

Sample Output 1

3

There are three subarrays ((A1,A2)(A_1, A_2), (A3)(A_3), and (A2,…,A6)(A_2, \dots, A_6)) whose sum equals KK.

Sample Input 2

2 -1000000000000000
1000000000 -1000000000

Sample Output 2

0

Constraints

1≤N≤2×1051 \leq N \leq 2 \times 10^5, ∣Ai∣≤109|A_i| \leq 10^9, ∣K∣≤1015|K| \leq 10^{15}.