#include <stdio.h> int main() { int n; scanf("%d ", &n); int g = n / 10; int p = 0; bool curr_group = true; char c; for(int i = 0; i < n; i++) { scanf("%c", &c); if(c == 'N') curr_group = false; if((i+1) % g == 0) { if(curr_group) p++; curr_group = true; } } printf("%d\n", p); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <stdio.h> int main() { int n; scanf("%d ", &n); int g = n / 10; int p = 0; bool curr_group = true; char c; for(int i = 0; i < n; i++) { scanf("%c", &c); if(c == 'N') curr_group = false; if((i+1) % g == 0) { if(curr_group) p++; curr_group = true; } } printf("%d\n", p); return 0; } |