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: Time Limit Exceeded

Solution code:
n = int(input())

ans = n
for i in range(1, int(n/2)+1):
  if n % i == 0:
    a, b = i, int(n/i)
    #print(a, b)
    if a > b:
      break
    
    lena, lenb = len(str(a)), len(str(b))
    f = lena if lena > lenb else lenb
    #print(f)
    ans = f if ans > f else ans
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = n
for i in range(1, int(n/2)+1):
  if n % i == 0:
    a, b = i, int(n/i)
    #print(a, b)
    if a > b:
      break
    
    f = max( len(str(a)), len(str(b)) )
    #print(f)
    ans = min(ans, f)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
rootn = int(math.sqrt(n))
ct = 0
for i in range(rootn,n+1):
  if n%i == 0:
    tmp = i
    while tmp//10 != 0:
     ct += 1  
     tmp = tmp//10   
    break
print(ct+1)

Submission status: Time Limit Exceeded

Solution code:
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                div = i
                if n == 1:
                    s = 1
                L.append(i)
                break
    return L


n = int(input())
if n == 1:
    print(1)
    exit()
divs = factorization(n)
N = [i for i in divs]  # N = bit探索する桁数
maxDigit = n
# Nの要素の全組み合わせが出力
for i in range(1, 1 << len(N)):
    output = []
    nonout = []
    outNum = 1
    nonOutNum = 1
    for j in range(len(N)):
        if ((i >> j) & 1) == 1:
            output.append(N[j])  # このjが今回探索するindexの1つ
            outNum *= N[j]
        else:
            nonout.append(N[j])
            nonOutNum *= N[j]
    # print("{} vs {}".format(outNum, nonOutNum))
    digitOut = 0
    digitNonOut = 0
    while outNum > 0:
        digitOut += 1
        outNum = int(outNum / 10)
    while nonOutNum > 0:
        digitNonOut += 1
        nonOutNum = int(nonOutNum / 10)
    if max(digitOut, digitNonOut) < maxDigit:
        maxDigit = max(digitOut, digitNonOut)
print(maxDigit)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
mul_list = []
for i in range(1, n+1):
    if n % i == 0:
        if i <= n / i:
            mul = [i, n/i]
            mul_list.append(mul)
        else:
            break
length = 10000000000000
result = 0
for line in mul_list:
    dif = len(str(line[1]))-len(str(line[0]))
    if dif < length:
       result = len(str(int(line[1])))
print(result)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
for i in range(int(math.sqrt(n)),n+1,1):
    if n%i==0:
        break
print(len(str(i)))

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
for i in range(int(math.sqrt(n)),n+1,1):
    if n%i==0:
        i=str(i)
#        print(i)
        print(len(i))
        break

Submission status: Time Limit Exceeded

Solution code:
def count_digits(n):
    count = 0
    while n > 0:
        n //= 10
        count += 1
    return count

N = int(input())
digits = count_digits(N)

for A in range(1, N+1):
    if N % A != 0:
        continue
    B = N // A
    maximum = max(count_digits(A), count_digits(B))
    digits = min(maximum, digits)

print(digits)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
res = 200
tmp = N
for i in range(1, N+1):
    if N%i == 0:
        if max(len(str(i)),len(str(int(N/i)))) < res:
            res = max(len(str(i)),len(str(int(N/i))))
    
    if tmp < N//i:
            break
    tmp = N//i
print(res)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
res = 200
tmp = N
for i in range(1, N+1):
    if N%i == 0:
        if max(len(str(i)),len(str(int(N/i)))) < res:
            res = max(len(str(i)),len(str(int(N/i))))
    
    if tmp < N/i:
            break
    tmp = N/i
print(res)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

divList = []

n = N

while n != 1:
    if n % 2 == 0:
        n = n // 2
        divList.append(2)
        continue
    if n % 3 == 0:
        n = n // 3
        divList.append(3)
        continue

    newN = n
    isFind = False
    for i in range(6, int(n**(0.5) + 2), 6):
        if n % (i - 1) == 0:
            divList.append(i - 1)
            newN = newN // (i - 1)
            isFind = True
        if n % (i + 1) == 0:
            divList.append(i + 1)
            newN = newN // (i + 1)
            isFind = True

        if isFind == True:
            break

    if isFind == False:
        divList.append(n)
        newN = 1
    n = newN

    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = set([(len(str(ab[0])), len(str(ab[1]))) for ab in a1])

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

divList = []

n = N

while n != 1:
    if n % 2 == 0:
        n = n // 2
        divList.append(2)
        continue
    if n % 3 == 0:
        n = n // 3
        divList.append(3)
        continue

    newN = n
    isFind = False
    for i in range(6, n + 1, 6):
        if n % (i - 1) == 0:
            divList.append(i - 1)
            newN = newN // (i - 1)
            isFind = True
        if n % (i + 1) == 0:
            divList.append(i + 1)
            newN = newN // (i + 1)
            isFind = True

        if isFind == True:
            break

    if isFind == False:
        divList.append(n)
        newN = 1
    n = newN

    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = set([(len(str(ab[0])), len(str(ab[1]))) for ab in a1])

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

divList = []

n = N

while n != 1:
    div = 1
    for i in range(2, n+1):
        if n % i == 0:
            div = i
            break
    divList.append(div)
    n = int(n / div)
    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = set([(len(str(ab[0])), len(str(ab[1]))) for ab in a1])

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

divList = []

n = N

while n != 1:
    div = 1
    for i in range(2, n+1):
        if n % i == 0:
            div = i
            break
    divList.append(div)
    n = int(n / div)
    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = [(len(str(ab[0])), len(str(ab[1]))) for ab in a1]

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
i = int(N**(1/2))
while N%i != 0:
  i += 1
print(len(str(i)))

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
Candidate=-(-math.sqrt(N)//1)
while N%Candidate!=0:
    if Candidate>N:
        break
    Candidate+=1
print(len(str(Candidate))-2)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
Candidate=-(-math.sqrt(N)//1)
while N%Candidate!=0:
    Candidate+=1
print(len(str(Candidate))-2)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
Candidate=-(-math.sqrt(N)//1)
tens=0
while N%Candidate!=0:
    Candidate+=1
while Candidate//pow(10,tens)!=0:
    tens+=1
print(tens)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

A = make_divisor_list(N)

B = []
keta = []

for a in A:
    b = int(N/a)
    B.append(b)

    aa = len(str(a))
    bb = len(str(b))

    f = max(aa,bb)
    keta.append(f)

print(min(keta))

Submission status: Time Limit Exceeded

Solution code:
def f(a, b):
    return max(len(str(int(x))) for x in (a, b)) 

n = int(input())

min_num = len(str(n))
for a in range(1, n//2):
    b = (n/a)
    if b % 1 == 0:
        min_num = min(min_num, f(a, b))
print(min_num)

Submission status: Time Limit Exceeded

Solution code:
import math
from itertools import product

N = int(input())


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


def F(a, b):
    a = int(math.log10(a)) + 1
    b = int(math.log10(b)) + 1
    return max(a, b)


p = prime_decomposition(N)

ans = float('inf')
for x in product([True, False], repeat=len(p)):
    a, b = 1, 1
    for i in range(len(p)):
        if x[i]:
            a *= p[i]
        else:
            b *= p[i]
    ans = min(ans, F(a, b))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
import math
sqN=math.sqrt(N)
sqN=math.floor(sqN)
i=sqN

while N%i!=0:
    i-=1
a=math.floor(math.log10(i))+1
b=math.floor(math.log10(N//i))+1
candA=max(a,b)
i=sqN
while N%i!=0:
    i+=1
a=math.floor(math.log10(i))+1
b=math.floor(math.log10(N//i))+1
candB=max(a,b)

print(min(candA,candB))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n=int(input())
def sqdivlist(n):
    lista=[]
    for i in range(1,int((n**0.5)//1)+1):
        if n%i==0:
            lista.append(str(i))
    return (lista)
lista2=[]
ans=[]
for j in range(len(sqdivlist(n))):
    lista2.append(int(n/int((sqdivlist(n))[j])))
    ans.append(max(len(str(sqdivlist(n)[j])),(len(str(lista2[j])))))
print(min(ans))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def sqdivlist(n):
    lista=[]
    for i in range(1,int((n**0.5)//1)+1):
        if n%i==0:
            lista.append(str(i))
    return (lista)
lista2=[]
for j in range(len(sqdivlist(n))):
    lista2.append(int(n/int((sqdivlist(n))[j])))
ans=[]
for k in range(len(sqdivlist(n))):
    ans.append(max(int(len(str(sqdivlist(n)[k]))), int(len(str(lista2[k])))))
print(min(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
import math
ans = len(str(n))
for i in range(math.floor(math.sqrt(n)),n+1):
    if n % i == 0:
        ans = len(str(i))
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

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

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

if is_prime(N) == True:
    ans = str(int(math.log10(N) + 1))
    print(ans)
    sys.exit()

if a.is_integer() == True:
    ans = str(int(math.log10(a) + 1))
    print(ans)
    sys.exit()

b = int(a)
for i in range(b,N + 1):
    for j in reversed(range(N // i + 1)):
        k = i * j
        if k < N:
            break
        if k == N:
            ans = str(int(math.log10(i) + 1))
            print(ans)
            sys.exit()

Submission status: Time Limit Exceeded

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

n = int(input())

nsr = sqrt(n)

for i in range(ceil(nsr),n+1):
    if n%i==0:
        ret = ceil(log10(i))
        if 10**ret==int(i):
            print(ret+1)
        else:
            print(ret)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
dv = []
dved = []
for i in range(1,n//2):
    if n%i==0 and not(i in dved):
        dv.append(i)
        dved.append(n//i) 
    if i in dved:
        break
print(len(str(dved[-1]))if len(dv)>0 else 1)

Submission status: Time Limit Exceeded

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)