All problems

Problem 84

Power of Two

Easy · 10 pts · Math, Bit Manipulation

Problem

You are given an integer N. Decide whether N is a power of two, that is, N = 2^k for some integer k >= 0. The powers of two are 1, 2, 4, 8, 16, ... Zero and negative numbers are never powers of two. A positive power of two has exactly one 1 bit in binary, so for N > 0 the test N & (N - 1) == 0 is enough. Repeatedly dividing by 2 while N is even also works.

Input

A single integer N.

Output

Print YES or NO.

Constraints

-2147483648 <= N <= 2147483647

Example input

16

Example output

YES

Explanation

16 = 2 × 2 × 2 × 2 = 2^4, and in binary it is 10000, with a single 1 bit. So the answer is YES.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Single Number Next: Number of Divisors