#include <cstdio> int main() { int n; char s[128]; scanf("%d %s", &n, s); const int k = n / 10; int res = 10; for (int i = 0; i < n;) { if ( s[i] == 'N' ) { res--; i += k - i % k; } else { i++; } } printf("%d\n", res); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <cstdio> int main() { int n; char s[128]; scanf("%d %s", &n, s); const int k = n / 10; int res = 10; for (int i = 0; i < n;) { if ( s[i] == 'N' ) { res--; i += k - i % k; } else { i++; } } printf("%d\n", res); return 0; } |