Skip to content

Commit

Permalink
Add 13871.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Feb 28, 2024
1 parent 6034a99 commit 79ca4c5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 13xxx/13871.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <vector>
using namespace std;

void solve(void) {
int n, c, s; cin >> n >> c >> s;
vector<int> x(c);
for (int i=0; i<c; i++) cin >> x[i];

int ans = (s == 1), cur = 1;
for (int i=0; i<c; i++) {
cur += x[i];
if (cur > n) cur = 1;
if (cur < 1) cur = n;
if (cur == s) ans++;
}
cout << ans;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

solve();
return 0;
}

0 comments on commit 79ca4c5

Please sign in to comment.