leminhkt

noname16 (PSEQ)

Mar 4th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
  5. #define FORn(i, n) for(ll i=1; i<=(n); i++)
  6. using namespace std;
  7.  
  8. int n, k, a[100005], res;
  9. int main(){
  10.     // freopen("PSEQ.inp", "r", stdin);
  11.     // freopen("PSEQ.out", "w", stdout);
  12.     // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  13.     cin>>n>>k;
  14.     FORn(i, n) cin>>a[i];
  15.     FORn(i, n){
  16.         int s=0;
  17.         FOR(j, i, n){
  18.             s+=a[j];
  19.             if(s==k) res++;
  20.         }
  21.     }
  22.     cout<<res;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment