#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(NULL); int n; std::string s; std::cin >> n >> s; int res = 0; int i = 0; while (i < s.length()) { bool ok = true; for (int k = 0; k < n/10; k++) if (s[i+k] == 'N') ok = false; if (ok) res++; i += n/10; } std::cout << res << "\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(NULL); int n; std::string s; std::cin >> n >> s; int res = 0; int i = 0; while (i < s.length()) { bool ok = true; for (int k = 0; k < n/10; k++) if (s[i+k] == 'N') ok = false; if (ok) res++; i += n/10; } std::cout << res << "\n"; } |