Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n, m;
- cin >> n >> m;
- vector <int> a(n);
- int cnt = 0;
- for (int i = 0; i < n; i++)
- {
- cin >> a[i];
- int s = 0;
- if (a[i] == m)
- cnt++;
- s += a[i];
- for (int j = i; j < a.size() - 1; j++)
- {
- if (s < m)
- s += a[j];
- else if (s > m)
- s = 0;
- else
- {
- cnt++;
- s = 0;
- }
- }
- }
- cout << cnt << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement