Skip to main content
Back to problems
Codeforces
Easy
Math
Number Theory
Funky Numbers

Find whether a number can be expressed as a sum of two distinct powers of 2.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Funky Numbers

Given an integer nn, determine whether it can be written as:

n=2a+2bn = 2^a + 2^b

for two different non-negative integers aa and bb.

In other words, check whether nn can be represented as the sum of two distinct powers of two.

If such a representation exists, print YES; otherwise print NO.

Notes

  • The two powers must be different.
  • A number is considered funky only if it has exactly two set bits in binary representation.

Input Format

  • A single integer nn.

Output Format

  • Print YES if nn can be represented as the sum of two distinct powers of two.
  • Otherwise print NO.

Constraints

  • 1n1 \le n.
  • The exact upper bound is not required for solving the problem; use integer-safe logic.
Examples
Sample cases returned by the problem API.

Example 1

Input

3

Output

YES

Explanation

3 = 20+22^{0}+2^1.

Example 2

Input

7

Output

NO

Explanation

7 = 111_2 has three set bits, so it cannot be written as the sum of exactly two distinct powers of two.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.