#include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <iomanip> #include <set> #include <list> #include <queue> #include <map> #include <vector> #include <stack> constexpr int N = 1e6 + 7; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n; std::cin >> n; int wynik = 0; int x = n / 10; std::string s; std::cin >> s; for (int i = 0; i < n; i += x) { bool bul = 1; for (int j = i; j < i + x; ++j) { if (s[j] == 'T') { continue; } else { bul = 0; } } if (bul == 1) { ++wynik; } } std::cout << wynik; }
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <iomanip> #include <set> #include <list> #include <queue> #include <map> #include <vector> #include <stack> constexpr int N = 1e6 + 7; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n; std::cin >> n; int wynik = 0; int x = n / 10; std::string s; std::cin >> s; for (int i = 0; i < n; i += x) { bool bul = 1; for (int j = i; j < i + x; ++j) { if (s[j] == 'T') { continue; } else { bul = 0; } } if (bul == 1) { ++wynik; } } std::cout << wynik; } |