Problem:


Score : 300 points

Problem Statement

You are given an integer N.

For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.

For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.

Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Constraints

1 \leq N \leq 10^{10}

N is an integer.

Input

The input is given from Standard Input in the following format:

N

Output

Print the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Sample Input 1

10000

Sample Output 1

3

F(A,B) has a minimum value of 3 at (A,B)=(100,100).

Sample Input 2

1000003

Sample Output 2

7

There are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.

Sample Input 3

9876543210

Sample Output 3

6



Sample input:
10000


Sample output:
3

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

n = int(math.sqrt(N))+1
#print(n)
def digit(x):
    if 1 <= x < 10:
        return 1
    elif 10 <= x <100:
        return 2
    elif 100<= x <1000:
        return 3
    elif 1000 <= x < 10000:
        return 4
    elif 10000 <= x < 100000:
        return 5
    elif 100000 <= x < 1000000:
        return 6
    elif 1000000 <= x < 10000000:
        return 7
    elif 10000000 <= x < 100000000:
        return 8
    elif 100000000 <= x < 10000000000:
        return 9
    else:
        return 10

while True:
    if(N % n == 0):
        k = N / n
        print(digit(k))
        break
    n-=1

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

n = int(math.sqrt(N))+1
#print(n)
def digit(x):
    if 100<= x <1000:
        return 3
    elif 1000 <= x < 10000:
        return 4
    elif 10000 <= x < 100000:
        return 5
    elif 100000 <= x < 1000000:
        return 6
    elif 1000000 <= x < 10000000:
        return 7
    elif 10000000 <= x < 100000000:
        return 8
    elif 100000000 <= x < 10000000000:
        return 9
    else:
        return 10

while True:
    if(N % n == 0):
        k = N / n
        print(digit(k))
        break
    n-=1

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

n = int(math.sqrt(N))+1
#print(n)
def digit(x):
    if 100<= x <1000:
        return 3
    elif 1000 <= x < 10000:
        return 4
    elif 10000 <= x < 100000:
        return 5
    elif 100000 <= x < 1000000:
        return 6
    elif 10**6 <= x < 10**7:
        return 7
    elif 10**7 <= x < 10**8:
        return 8
    elif 10**8 <= x < 10**9:
        return 9
    else:
        return 10

while True:
    if(N % n == 0):
        k = N / n
        print(digit(k))
        break
    n-=1

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
sN=math.sqrt(N)
ans=10000
for i in range(1,int(sN)):
    if N%i==0:
        k1=N/i
        k=int(k1)
    
        if ans > max(len(str(i)),len(str(k))):
            ans=max(len(str(i)),len(str(k)))

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
sN=math.sqrt(N)
ans=10000
for i in range(1,int(sN)):
    k1=N/i
    k=int(k1)
    if i*k ==N:
        if ans > max(len(str(i)),len(str(k))):
            ans=max(len(str(i)),len(str(k)))

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ans = len(str(N))

for k in range(1,int(math.sqrt(N))):
    if N%k==0:
        ans=min(ans,max(len(str(k)),len(str(N//k))))

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = float('inf')

for i in range(1, int(n**0.5)):
  if n % i == 0:
    if max(len(str(i)), len(str(n//i))) < ans:
      ans = max(len(str(i)), len(str(n//i)))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
res = float("inf")
for i in range(2, int(math.sqrt(n))):
    if n % i == 0 and res > max(len(str(n//i)), len(str(i))):
        res = max(len(str(n//i)), len(str(i)))

print(res if res != float("inf") else len(str(n)))

Submission status: Wrong Answer

Solution code:
from math import sqrt
from math import log10
n=int(input())

i=1
ans=13
j=0

while i<=sqrt(n):
    if n%i==0:
        j=n//i
        ans=int(min(ans,max(log10(i)+1,log10(j)+1)))
        print(i,j)
    i+=1
if j==0:
    ans=int(max(log10(i)+1,log10(j)+1))
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n = int(input())

def cntd(x):
    digits = 0

    while x/10>0:
        x = x//10
        digits += 1
    return digits

ret = cntd(n)
i = 1
while i**2<n:
    if n%i==0:
        a = cntd(i)
        b = cntd(n//i)
        cur = max(a,b)
        if ret>cur:
            ret = cur
    i += 1

print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt,ceil,log10

n = int(input())

nsr = sqrt(n)

def cntd(x):
    return len(str(x))

ret = cntd(n)
i = 1
while i**2<n:
    if n%i==0:
        a = cntd(i)
        b = cntd(n//i)
        cur = max(a,b)
        if ret>cur:
            ret = cur
    i += 1

print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt,ceil,log10

n = int(input())

nsr = sqrt(n)

def cntd(x):
    return len(str(x))

ret = cntd(n)
i = 1
while i**2<n:
    if n%i==0:
        a = cntd(i)
        b = cntd(n//i)
        ret = min(max(a,b), ret)
    i += 1

print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt,ceil,log10

n = int(input())

nsr = sqrt(n)

def cntd(x):
    ret = ceil(log10(x))
    if 10**(ret)==int(x):
        return ret+1
    else:
        return ret

ret = cntd(n)
i = 1
while i**2<n:
    if n%i==0:
        a = cntd(i)
        b = cntd(n//i)
        ret = min(max(a,b), ret)
    i += 1

print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt,ceil,log10

n = int(input())

nsr = sqrt(n)

x = n
i = 1
while i**2<n:
    if n%i==0:
        x = n//i
    i += 1

ret = ceil(log10(x))
if 10**(ret)==int(x):
    print(ret+1)
else:
    print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 10**10

def F(A,B):
    return max(len(str(A)), len(str(B)))
rootN = int(N**.5)

for i in range(1,rootN):
    if N%i != 0:
        continue
    else:
        ans = min(ans,F(N//i,i))

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt
n = int(input())
digit = 10
for a in range(int(sqrt(n)), 0, -1):
    b = n / a
    if digit > len(str(b)) and b == int(b):
        digit = len(str(int(b)))
print(digit)

Submission status: Wrong Answer

Solution code:
from math import sqrt
def calc_digit(n):
    res = 0
    while n != 0:
        res += 1
        n //= 10
    return res

n = int(input())
res = calc_digit(n)
for a in range(1, int(sqrt(n))):
    if n % a != 0:
        continue
    b = n // a
    f = max(calc_digit(a), calc_digit(b))
    res = min(res, f)
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())

i = 2
table = []
while i * i <= n:
    while n % i == 0:
        n //= i
        table.append(i)
    i += 1
if n > 1:
    table.append(n)

a, b = 1, 1
c, d = 1, 1
for i in table[::-1]:
    a, b = min(a, b) * i, max(a, b)
for i in table:
    c, d = min(c, d) * i, max(c, d)
print(min(max(len(str(a)), len(str(b))), max(len(str(c)), len(str(d)))))

Submission status: Wrong Answer

Solution code:
n = int(input())

i = 2
table = []
while i * i <= n:
    while n % i == 0:
        n //= i
        table.append(i)
    i += 1
if n > 1:
    table.append(n)

a, b = 1, 1
for i in table[::-1]:
    a, b = min(a, b) * i, max(a, b)
print(max(len(str(a)), len(str(b))))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
m = math.ceil(math.sqrt(n))

ans = len(str(n))
for i in range(2, m):
    if n % i == 0:
        tmp = max(len(str(i)), len(str(int(n/i))))
        ans = min(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
if n<10:
    print(1)
    sys.exit()
ans=float("inf")
for i in range(1,int(n**(1/2))):
    if n%i==0:
        ans=min(ans,len(str(int(n//i))))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

def get_divisor_list(N):
    divisor_list = []

    for i in range(1, int(math.sqrt(N)) + 1):
        if N % i == 0:
            divisor_list.append([i, N //i])

    return divisor_list

divisor_list_max = [max(x) for x in get_divisor_list(N)]


print(len(str(divisor_list_max)))

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
a = math.sqrt(n)

if n % a == 0.0:
    b = int(math.log10(a)) + 1
    print(b)
else:
    a = int(a)
    while n % a != 0:
        a = a -1
    b = int(math.log10(a)) + 1
    print(b)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
a = math.sqrt(n)

if n % a == 0.0:
    b = int(math.log10(a)) + 1
    print(b)
else:
    a = int(a)
    while n % a != 0.0:
        a = a -1
    b = int(math.log10(a)) + 1
    print(b)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
a = math.sqrt(n)

if n % a == 0.0:
    b = math.log10(a) + 1
    print(b)
else:
    a = int(a)
    while n % a != 0.0:
        a = a -1
    b = math.log10(a) + 1
    print(b)