Sequences
Practice
3.3 (13 votes)
Algorithms
Binary search
Math
Searching
Problem
44% Success 2021 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given two integers \(X\) and \(Y\). Your task is to determine the sequence of real numbers with the minimum size such that the sum and product of the numbers in the sequence are \(X\) and \(Y\) respectively. Also, print the size of the sequence only.

If no such sequences exist, then print \(-1\).

Input format

  • First line: \(t\) denoting the number of test cases
  • Next \(t\) lines: Two space-separated integers \(X\) and \(Y\)

Output format

For each test case, print a single line containing the answer.

Constraints

\(1 \le t \le 100\)

\(1\le X,Y \le10^9\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
20 votes
Tags:
Binary SearchEasySearching
Points:30
5 votes
Tags:
Binary SearchAlgorithms
Points:30
14 votes
Tags:
AlgorithmsBinary SearchEasySearching