Back to problems Sign in to unlock
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 , determine whether it can be written as:
for two different non-negative integers and .
In other words, check whether 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 .
Output Format
- Print
YESif can be represented as the sum of two distinct powers of two. - Otherwise print
NO.
Constraints
- .
- 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 = ^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
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.