**Problem Link**

UKP1

**Author:**

ujjk29

## Editorialist:

ujjk29

**Difficulty:**

Easy-medium

**Prerequisites:**

Basic Maths, Binary search.

**Problem:**

You need to find all x for given y such that f(x)=y.

**Explanation:**

Let us consider a number x. And suppose that we divide it by two exactly ‘a’ times, and then we would be left with some number ‘b’.

Then the result would be (b*(b-1))/2 + b*((2^a)-1).

As this equation is increasing for a fixed ‘a’ we can use binary search over ‘b’ to get values.

This can be also solved by finding solutions of above quadratic equation.

**Solution Code**

Quadratic Solution

Using Binary Search Solution