#include <bits/stdc++.h> using namespace std; int n, c, t, cnt; string ciag; int main(){ cin>>n; t=n/10; cin>>ciag; for(int i=0; i<n; i++){ if(ciag[i]=='N') cnt=1; if(((i+1)%t==0)&& (cnt==0)) { c++; } if((i+1)%t==0) cnt=0; } cout<<c; }
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 n, c, t, cnt; string ciag; int main(){ cin>>n; t=n/10; cin>>ciag; for(int i=0; i<n; i++){ if(ciag[i]=='N') cnt=1; if(((i+1)%t==0)&& (cnt==0)) { c++; } if((i+1)%t==0) cnt=0; } cout<<c; } |