#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int ile = n/10; bool dobrze = 1; string s; cin >> s; int sum = 0; for(int i = 0; i < n; i++){ if(s[i] == 'N') dobrze = 0; if((i+1) % ile == 0){ if(dobrze)sum++; dobrze = 1; } } cout << sum << '\n'; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int ile = n/10; bool dobrze = 1; string s; cin >> s; int sum = 0; for(int i = 0; i < n; i++){ if(s[i] == 'N') dobrze = 0; if((i+1) % ile == 0){ if(dobrze)sum++; dobrze = 1; } } cout << sum << '\n'; return 0; } |