Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool esPotenciaDe2(string &s)
- {
- int ocurrencias = 0;
- for(int i = 0; i < s.length() && ocurrencias <= 1; ++i)
- if(s[i] == '1')
- ++ocurrencias;
- return ocurrencias == 1;
- }
- int main() {
- int t;
- cin >> t;
- while(t--)
- {
- string s;
- cin >> s;
- if(esPotenciaDe2(s))
- cout << "SI" << endl;
- else
- cout << "NO" << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment