Untitled
unknown
plain_text
2 years ago
552 B
10
Indexable
#include <iostream>
#include <regex>
int main() {
std::regex pattern("^10*$"); // regex pattern to match binary strings that represent powers of 2
int n; // number of test strings
std::cin >> n;
for (int i = 0; i < n; i++) {
std::string s;
std::cin >> s;
// Check if the string matches the pattern
if (std::regex_match(s, pattern)) {
std::cout << "True" << std::endl;
} else {
std::cout << "False" << std::endl;
}
}
return 0;
}
Editor is loading...