#include <iostream> #define GET_VALUE(value_) (std::cin >> (value_)) #define FOR(size_, iname_) for (int iname_ = 0; iname_ < (size_); ++iname_) #define GETT(type_, name_) for (type_ name_, name_##_marker_ = 1; name_##_marker_ && (GET_VALUE(name_), 1); --name_##_marker_) #define GET(name_) GETT(int, name_) #define GETS(name_) for (std::string name_, name_##_marker_ = "1"; name_##_marker_ == "1" && std::cin >> name_; name_##_marker_ = "") #define PUTN(value_) std::cout << (value_) #define PUT(value_) PUTN(value_) << "\n" int main() { GET(n) GETS(s) { char const *p = &s[0]; int result = 0; int n10 = n / 10; FOR(10, i) { int error = 0; FOR(n10, j) error |= (*p++ != 'T'); result += !error; } PUT(result); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> #define GET_VALUE(value_) (std::cin >> (value_)) #define FOR(size_, iname_) for (int iname_ = 0; iname_ < (size_); ++iname_) #define GETT(type_, name_) for (type_ name_, name_##_marker_ = 1; name_##_marker_ && (GET_VALUE(name_), 1); --name_##_marker_) #define GET(name_) GETT(int, name_) #define GETS(name_) for (std::string name_, name_##_marker_ = "1"; name_##_marker_ == "1" && std::cin >> name_; name_##_marker_ = "") #define PUTN(value_) std::cout << (value_) #define PUT(value_) PUTN(value_) << "\n" int main() { GET(n) GETS(s) { char const *p = &s[0]; int result = 0; int n10 = n / 10; FOR(10, i) { int error = 0; FOR(n10, j) error |= (*p++ != 'T'); result += !error; } PUT(result); } } |