#include <iostream> using namespace std; int n, ans, is_point, gr; string s; int main() { cin>>n; cin>>s; gr=n/10; is_point=1; for(int i=0; i<n; i++){ if(s[i]=='N') is_point=0; if((i+1)%gr==0){ ans+=is_point; is_point=1; } } cout<<ans; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> using namespace std; int n, ans, is_point, gr; string s; int main() { cin>>n; cin>>s; gr=n/10; is_point=1; for(int i=0; i<n; i++){ if(s[i]=='N') is_point=0; if((i+1)%gr==0){ ans+=is_point; is_point=1; } } cout<<ans; } |