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\)
Submissions
Please login to view your submissions
Editorial