알고리즘

[알고리즘] 백준 11966 - 2의 제곱인가? (C++)

blueberrysoda 2024. 10. 12. 23:54

[문제 링크] : https://www.acmicpc.net/problem/11966

#include <iostream>
using namespace std;
 
int main(){
    int N;
    cin >> N;
 
    if(N == 1){
        cout << 1 << "\n";
        return 0;
    }
 
    int squareNum = 1;
    for(int i=0; i<30; i++){
        squareNum *= 2;
        
        if(N == squareNum){
            cout << 1 << "\n";
            return 0;
        }
    }
 
    cout << 0 << "\n";

    return 0;
}