Competitive Programming Solutions

GitHub
back to dashboard

A. Power Of Two

Codeforces - Sheet #6 (Math - Geometry) · limit: 1s · memory: 256MB · view on codeforces

input

8

output

YES
Main.java
static void solve() {

        // Write your solution here
        long n = in.nextLong();
        if (n <= 0) {
            out.println("NO");
            return;
        }

        while (n % 2 == 0) {
            n /= 2;
        }

        out.println(n == 1 ? "YES" : "NO");
    }