Sequences

3.3

13 votes
Algorithms, Binary Search, Math, Searching
Problem

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

1t100

1X,Y109

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

.The least possible size sequence is {5}

Editor Image

?