#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); std::string s; int n; std::cin >> n >> s; int m = n/10; int c = 0; int sum = 0; int e = 1; for(auto i=0; i<s.size(); i++) { if(s[i]=='N') e = 0; c++; if(c == m) { sum += e; e = 1; c=0; } } std::cout << sum << "\n"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); std::string s; int n; std::cin >> n >> s; int m = n/10; int c = 0; int sum = 0; int e = 1; for(auto i=0; i<s.size(); i++) { if(s[i]=='N') e = 0; c++; if(c == m) { sum += e; e = 1; c=0; } } std::cout << sum << "\n"; return 0; } |