Rohan and Digits

0

0 votes
Problem

Rohan needs your help to solve the following problem.

For 2 integers X and Y:

  • f(X,Y)=max(NumOfDigits(X),NumOfDigits(Y))where the function NumOfDigits(x) represents the number of digits present in the decimal notation of x.

Rohan has been given an integer N. He has to find the minimum value of f(X,Y) as (X,Y) ranges over all pairs of positive integers such that N=XY.

Constraints

1N1010
1T102

Input Format

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases is as follows. The first line of each test case contains the number N.

Output Format

Find the minimum value of f(X,Y) as (X,Y) ranges over all pairs of positive integers such that N=XY.

Sample Input
2
10
223
Sample Output
1
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For 10:f(X,Y) has a minimum value of 1 at (X,Y)=(2,5)
For 223:f(X,Y) has a minimum value of 3 at (X,Y)=(1,223)
 

Editor Image

?