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:
from numba import jit
n = int(input())
a = []

while n%2 == 0:
    a.append(2)
    n //= 2

f = 3
while f**2 <= n:
    while n%f == 0:
        a.append(f)
        n //= f
    f += 2
if n != 1:
    a.append(n)

def cal(a):
    ans, num = 0, len(a)
    diff = float('inf')
    for i in range(2**num):
        b = ['-']*num
        c0, c1 = 1, 1
        for j in range(num):
            if ((i>>j)&1):
                b[num-1-j] = '+'
        for k in range(num):
            if b[k] == '+':
                c0 *= a[k]
            else:
                c1 *= a[k]
        if abs(c0-c1) < diff:
            ans = max(len(str(c0)), len(str(c1)))
            diff = abs(c0-c1)
    return ans
print(cal(a))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = []

while n%2 == 0:
    a.append(2)
    n //= 2

f = 3
while f**2 <= n:
    while n%f == 0:
        a.append(f)
        n //= f
    f += 2
if n != 1:
    a.append(n)

ans, num = 0, len(a)
diff = float('inf')
for i in range(2**num):
    b = ['-']*num
    c0, c1 = 1, 1
    for j in range(num):
        if ((i>>j)&1):
            b[num-1-j] = '+'
    for k in range(num):
        if b[k] == '+':
            c0 *= a[k]
        else:
            c1 *= a[k]
    if abs(c0-c1) < diff:
        ans = max(len(str(c0)), len(str(c1)))
        diff = abs(c0-c1)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

answer = [i for i in range(1, N+1) if N % i ==0]
answer_r = sorted(answer, reverse=True)

s = [[A,B] for A, B in zip(answer, answer_r)]

for i in range(len(s)):
    if i == len(s)//2:
        ans = s[i]
        break

if len(str(ans[0])) > len(str(ans[1])):
    a = ans[0]
else:
    a = ans[1]

print(len(str(a)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

nummin = len(str(N))
for i in range(int(N/2)+1):
    if N % (i+1) == 0:
        a = i+1
        b = int(N/(i+1))
        numa = len(str(a))
        numb = len(str(b))
        F = max(numa, numb)
        if nummin > F:
            nummin = F
print(nummin)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[]
t=int(n**0.5)
while len(l)==0:
    if n%t==0:
        l.append((t,n//t))
    t+=1
x,y=l[0][0],l[0][1]
ans=max(len(list(str(x))),len(list(str(y))))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list = []

for ni in range(1,n+1):
    if ni ** 2 <= n:
        if n % ni == 0:
            list.append(max(len(str(ni)),len(str(n//ni))))
print(min(list))

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
ans = 10
a = int(math.sqrt(n))
for i in range(a, n+1):
    q, mod = divmod(n, i)
    if mod == 0:
        print(max(map(len, map(str, [i, q]))))
        exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def f(a, b):
    x = max(a, b)
    return len(str(x))

results = []

for i in range(1, n + 1):
    if n % i == 0:
        a = i
        b = n / i
    result = f(a, b)
    results.append(result)

print(min(results))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

for a in range(1,n**2+1):
    if n%a==0:
        b=n//a
        sa=str(a)
        sb=str(b)
        if a<=b:
             ans=len(sb)
        else:
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

for a in range(1,n**2+1):
    if n%a==0:
        b=n//a
        sa=str(a)
        sb=str(b)
        
        #print(a,b,len(sa),len(sb))
        if len(sb)-len(sa)==0:
            ans=len(sb)
            break
        elif len(sb)-len(sa)>=1:
             ans=len(sb)
        else:
            #print(b,sb,len(sa),len(sb))
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

for i in range(1,n**2+1):
    a=i
    if n%a==0:
        b=n//a
        sa=str(a)
        sb=str(b)
        
        #print(a,b,len(sa),len(sb))
        if len(sb)-len(sa)==0:
            ans=len(sb)
            break
        elif len(sb)-len(sa)>=1:
             ans=len(sb)
        else:
            #print(b,sb,len(sa),len(sb))
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
F = 10

for i in range(1,N+1):
    if N%i==0:
        F=min(F,max(len(str(i)),len(str(int(N/i)))))
print(F)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

for i in range(1,n+1):
    a=i
    if n%a==0:
        b=n//a
        sa=str(a)
        sb=str(b)
        
        #print(a,b,len(sa),len(sb))
        if len(sb)-len(sa)>=0:
            ans=len(sb)
        else:
            #print(b,sb,len(sa),len(sb))
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = int(n**0.5)

while n%x!=0:
    x += 1
y = n//x
print(len(str(max(x,y))))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = round(n**0.5)

while n%x!=0:
    x += 1
y = n//x
print(len(str(max(x,y))))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n%i == 0:
            return False
    return True

if is_prime(n):
    ans = len(str(n))
else:
    x = int(n**0.5)
    while n%x!=0:
        x += 1
    y = n//x
    ans = max(len(str(x)), len(str(y)))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = input()
n = int(s)

# 約数を求める処理
answer = n

for i in range(1,n + 1):
    for j in range(i, n + 1):
        if i * j == n:
            x = i
            y = j
            count_i = 0
            count_j = 0
            while (x > 0):
                x = int(x/10)
                count_i += 1
            while (y > 0):
                y = int(y/10)
                count_j += 1
            answer = min(max(count_i,count_j),answer)
            break

print(answer)

Submission status: Time Limit Exceeded

Solution code:
s = input()
n = int(s)

# 約数を求める処理
answer = n

for i in range(1,n + 1):
    for j in range(1, n + 1):
        if i * j == n:
            x = i
            y = j
            count_i = 0
            count_j = 0
            while (x > 0):
                x = int(x/10)
                count_i += 1
            while (y > 0):
                y = int(y/10)
                count_j += 1
            answer = min(max(count_i,count_j),answer)
            break

print(answer)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = []
for a in range(1, N+1):
  if N % a == 0:
    b = N // a
    s = max(len(str(a)), len(str(b)))
    l.append(int(s))
print(min(l))

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
from copy import deepcopy
from functools import reduce
from operator import mul
n = int(input())
def pf(n):
    pfs = []
    while n % 2 == 0:
        pfs.append(2)
        n //= 2
    for i in range(3, int(sqrt(n)+1), 2):
        while n % i == 0:
            pfs.append(i)
            n //= i
    if n > 2:
        pfs.append(n)
    return pfs
def partition(pfs):
    subsets = [[]]
    for i in range(len(pfs)):
        for j in range(len(subsets)):
            c = deepcopy(subsets[j])
            subsets.append(c + [i])
    return subsets

pfs = pf(n)
Asubs = partition(pfs)
def digits(n):
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans

def calculate(Asubs):
    minSoFar = 10
    for Asub in Asubs:
        if Asub == []:
            Asum = 1
        else:
            Asum = reduce(mul, [pfs[i] for i in Asub])
        Bsub = [pfs[i] for i in range(len(pfs)) if i not in Asub]
        if Bsub == []:
            Bsum = 1
        else:
            Bsum = reduce(mul, Bsub)
        if max(digits(Asum), digits(Bsum)) < minSoFar:
            minSoFar = max(digits(Asum), digits(Bsum))
    return minSoFar
print (calculate(Asubs))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
n = int(input())
m = int(sqrt(n))
lst = []
for i in range(2, m + 1):
    if n % i == 0:
        j = 0
        while True:
            if n % i == 0:
                n //= i
                j += 1
            else:
                for k in range(j):
                    lst.append(i)
                break

lst.append(n)

ans = float("INF")
for i in range(2 ** len(lst)):
    num1 = 1
    num2 = 1
    for j in range(len(lst)):
        if (i >> j) & 1:
            num1 *= lst[j]
        else:
            num2 *= lst[j]
    ans = min(ans, max(len(str(num1)), len(str(num2))))
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def f(a, b):
    str_a = str(a)
    len_a = len(str_a)
    str_b = str(b)
    len_b = len(str_b)

    return len_a if len_a > len_b else len_b

N = int(input())

min = 10**10
for i in range(1, 10 ** len(str(N))//2):
    a = i
    if N % a == 0:
        b = int(N / a)
    else:
        continue

    if len(str(a)) > len(str(N)) // 2 + 1:
        break

    ret = f(a, b)
    if min > ret:
        min = ret

print(min)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for i in range(int(N**0.5),N+1):
    if N%i==0:
        print(len(str(i)))
        exit(0)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
for i in range(int(math.sqrt(N)),N+1):
    j=N//i
    if i*j==N:
        print(len(str(i)))
        exit(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

yaku = []

for i in range(1, N+1):
    if N % i == 0:
        if i in yaku:
            break
        if N/i <= i:
            yaku.append(i)
            break
        yaku.append(i)
        yaku.append(int(N/i))
yaku.sort()
ans = str(yaku[len(yaku)//2])
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 10
for i in range(1, n+1):
    if n % i == 0:
        if len(str(max(i, n/i))) <= ans:
            ans = len(str(max(i, n/i)))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
factors = []
while n%2 == 0:
    factors.append(2)
    n //=2

for f in range(3, int(n**0.5)+ 1, 2):
    while n%f == 0:
        factors.append(f)
        n //= f
if n != 1:
    factors.append(n)

nf = len(factors)

fab = 11
sset = set()
als = 2**nf
for i in range(als):
    if als^i in sset:
        continue
    sset.add(i)
    
    a = 1
    b = 1
    for j in range(nf):
        if (i>>j)&1:
            a *= factors[j]
        else:
            b *= factors[j]

    fab = min(fab, max(len(str(a)), len(str(b))))
print(fab)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
factors = []
while n%2 == 0:
    factors.append(2)
    n //=2

for f in range(3, int(n**0.5)+ 1, 2):
    while n%f == 0:
        factors.append(f)
        n //= f
if n != 1:
    factors.append(n)

nf = len(factors)

fab = 11
for i in range(2**nf):
    a = 1
    b = 1
    for j in range(nf):
        if (i>>j)&1:
            a *= factors[j]
        else:
            b *= factors[j]

    fab = min(fab, max(len(str(a)), len(str(b))))
print(fab)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for n in range(int(math.sqrt(N)), N+1):
    if N % n == 0:
        print(int(math.log10(n)) + 1)
        exit()
print(int(math.log10(N)))

Submission status: Time Limit Exceeded

Solution code:
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

n=int(input())
if is_prime(n):
    print(len(str(n)))
    exit()

ns=int(math.sqrt(n)//1)

for i in range(ns,n+1):
    a=n/i
    if a%1==0:
        s=i
        break
s=str(s)
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
n=int(input())
ns=int(sqrt(n)//1)

for i in range(ns,n+1):
    a=n/i
    if a%1==0:
        s=i
        break
s=str(s)
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
# qiitaにはbit全探索とは書いてないけど、bitが良さげ。
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
fac_list = factorization(n)

p = []
for i in range(len(fac_list)):
    for j in range(fac_list[i][1]):
        p.append(fac_list[i][0])

l = n
for i in range(2 ** len(p)):
    a = 1
    for j in range(len(p)):
        if ((i >> j) & 1):
            a *= p[j]
    b = int(n/a)
    l = min(l, max(len(str(a)),len(str(b))))
print(l)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
answer = []
for i in range(1,N+1):
  j = N / i
  if j == int(j):
    answer.append(max(len(str(i)),len(str(int(j)))))
print(min(answer))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
n = len(str(N))

for i in range(1,N-1):
    if N % i == 0:
        A = i
        B = N // A
        if A >= B:
            n1 = len(str(A))
            if n1 < n:
                n = n1
        else:
            n1 = len(str(B))
            if n1 < n:
                n = n1
    else:
        continue

print(n)

Submission status: Time Limit Exceeded

Solution code:
def f(a,b):
  return max(len(str(a)),len(str(b)))

N = int(input())
n = N
ans = N

for _ in range(1,int(n/2)+1):
  if n % _ == 0:
#    print("{}: {} {}".format(f(_,N/_),_,int(N/_)))
    if ans >= f(_,int(N/_)):
      ans = f(_,int(N/_))
    else:
      break
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
k = int(math.sqrt(n))
for i in range(k,n+1):
  if n%i == 0:
    a = i
    break
s = int(math.log(a,10))+1
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans=len(str(N))
for i in range(1, N+1):
    A=i
    B=N//A
    if A*B==N:
        ans = min(max(len(str(A)), len(str(B))), ans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def func(i, j):
  il = len(str(i))
  jl = len(str(j))
  if il > jl:
    return il
  return jl

n = int(input())
min = len(str(10**10))
for i in range(1, n+1):
  if n % i == 0:
    if i > n/i:
      break
    fr = func(i, int(n/i))
    if min > fr:
      min = fr
print(min)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

count=0
lis=[]


for i in range(1,N+1):
	if N/i==N//i:
		if N/i < i:
			break
		lis.append(i)

llis=[]
for x in lis:
	y = N / x
	mm=max([x,y])

	ketasuu=len(str(int(mm)))
	llis.append(ketasuu)


print(min(llis))

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
lim=math.ceil(math.sqrt(n))
cnt=0
rec=0

for i in range(lim, n+1):
  if n%i==0:
    print(len(str(i)))
    exit()
  if n%(i+1-lim)==0 and cnt==0:
    rec=n/(i+1-lim)
    cnt+=1
  if i>=rec:
    print(len(str(rec)))
    exit()

Submission status: Time Limit Exceeded

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

for i in range(lim, n+1):
  if n%i==0:
    print(len(str(i)))
    exit()
  elif (n+1)/2<i:
    print(len(str(n)))
    exit()

Submission status: Time Limit Exceeded

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

for i in range(lim, n+1):
  if n%i==0:
    print(len(str(i)))
    exit()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 17:19:32 2020

@author: NEC-PCuser
"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
                arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

if __name__ == "__main__":
    N = int(input())
    l = factorization(N)
    minimu = 10 ** 10
    ans = 0
    for i in range(0, 2**len(l)):
        a = 1
        b = 1
        for j in range(0, len(l)):
            if ((i >> j) & 1):
                a *= l[j]
            else:
                b *= l[j]
        if (abs(a - b) < minimu):
            minimu = abs(a - b)
            ans = max([len(str(a)), len(str(b))])
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import *
def p(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
ans=10
a=p(int(input()))
a+=[1,1]   
c=1
for i in a:
    c*=i
for i in range(1,len(a)//2+1):
    for j in combinations(a,i):
        b=1
        for k in j:
            b*=k
        ans=min(ans,max(len(str(b)),len(str(c//b))))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = 0
B = 0
num = 0
ans = 10**10

for i in range(1, N+1):
  if N%i == 0:
    A = len(str(i))
    B = len(str(N//i))
    num = max(A, B)
    ans = min(ans, num)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

while n<= N:
  if(N % n == 0):
    break
  else:
    n += 1
    
print(len(str(n)))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
from itertools import product

n = int(input())

def prime_factrize(a):
    ret = []
    while a%2 == 0:
        ret.append(2)
        a//=2
    f = 3
    while f * f <= a:
        if a % f == 0:
            ret.append(f)
            a//=f
        else:
            f+=2
    if a != 1:
        ret.append(a)
    return ret

f = prime_factrize(n)

def func(a, b):
    a = len(str(a))
    b = len(str(b))
    return max(a, b)

ans = float('inf')
for bit in product([0, 1], repeat=(len(f))):
    a = 1
    b = 1
    for i, v in enumerate(bit):
        if v == 0: a*=f[i]
        else: b*=f[i]
    ans = min(ans, func(a, b))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
i = 1
divisor = (1 + n) // 2
min_value = 10 ** 10 + 1
while i <= divisor:
    if n % i == 0:
        divisor = min(n // i, divisor)
        if max(len(str(i)),len(str(n // i))) > min_value:
            break
        min_value = min(min_value,max(len(str(i)),len(str(n // i))))
    i += 1
print(min_value)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
i = 1
divisor = (1 + n) // 2
min_value = 10 ** 10 + 1
while i <= divisor:
    if n % i == 0:
        divisor = n // i
        if max(len(str(i)),len(str(n // i))) > min_value:
            break
        min_value = min(min_value,max(len(str(i)),len(str(n // i))))
    i += 1
print(min_value)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
i = 1
divisor = n
min_value = 10 ** 10 + 1
while i <= divisor:
    if n % i == 0:
        divisor = n // i
        if max(len(str(i)),len(str(n // i))) > min_value:
            break
        min_value = min(min_value,max(len(str(i)),len(str(n // i))))
    i += 1
print(min_value)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
i = 1
min_value = 10 ** 9 + 1
while i <= n:
    if n % i == 0:
        if max(len(str(i)),len(str(n // i))) > min_value:
            break
        min_value = min(min_value,max(len(str(i)),len(str(n // i))))
    i += 1
print(min_value)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lis = []

for a in range(1, n+1):
  if n % a == 0:
    if len(str(a)) <= len(str(int(n/a))):
      lis.append(max(a, int(n/a)))
    else:
      break

print(len(str(min(lis))))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = 1
b = 1
mx = 10 ** 10
while (a <= b and a <= n):
    if n % a == 0:
        b = int(n / a)
        mx = min(mx, max(a, b))
    a += 1
print(len(str(mx)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = 1
b = 1
mx = 10 ** 10
while (a <= b):
    if n % a == 0:
        b = int(n / a)
        mx = min(mx, max(a, b))
    a += 1
print(len(str(mx)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans1 = 0

A = '1'
B = str(N)

if len(A)>=len(B):
    ans = len(A)
else:
    ans = len(B)
    
for i in range(2,N+1):
    A = i
    if N%A==0:
        B = int(N / A)
        A = str(A)
        B = str(B)
#        print(A, B)
        if len(A)>=len(B):
            ans1 = len(A)
        else:
            ans1 = len(B)
        if ans1 <= ans:
            ans = ans1
    if len(str(A))==len(str(B)):
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def F(A, B):
    return max(len(str(A)), len(str(B)))

ans = 1000000000
for A in range(1, N+1):
    if N%A == 0:
        B = int(N / A)
        if F(A, B) < ans:
            ans = F(A, B)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
from itertools import product
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg //= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg //= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    min = sys.maxsize
    for bit in range(2 ** len(p)):
        a = 1
        b = 1
        for i in range(len(p)):
            if ((bit >> i) & 1):
                a *= p[i]
            else:
                b *= p[i]
        if min > a and a >= b:
            min = a
        elif min > b and b > a:
            min = b
    print(len(str(min)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = float('inf')
temp = 0
for i in range(1,(n//2)+2):
    if n%i == 0:
        temp = max(i, n//i)
        ans = min(temp, ans)
print(len(str(ans)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = float('inf')
temp = 0
for i in range(1,(n//2)+2):
    if n%i == 0:
        temp = max(len(str(i)), len(str(n//i)))
        ans = min(temp, ans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = float('inf')
temp = 0
for i in range(1,n+1):
    if n%i == 0:
        temp = max(len(str(i)), len(str(n//i)))
        ans = min(temp, ans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
from itertools import product
import numpy as np
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg //= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg //= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    q = np.array(p)
    r = q - 1
    min = sys.maxsize
    for bit in product(range(2), repeat=len(p)):
        c = r * bit
        a = np.prod(c + 1)
        b = np.prod(q - c)
        if len(str(a)) >= len(str(b)):
            if min > len(str(a)):
                min = len(str(a))
        else:
            if min > len(str(b)):
                min = len(str(b))
    print(min)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
from itertools import product
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg //= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg //= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    min = sys.maxsize
    for bit in range(2 ** len(p)):
        a = 1
        b = 1
        for i in range(len(p)):
            if ((bit >> i) & 1):
                a *= p[i]
            else:
                b *= p[i]
        if min > len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b)):
            min = len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b))
    print(min)

Submission status: Time Limit Exceeded

Solution code:
import math
 
N=int(input())
 
a=math.ceil(math.sqrt(N))
 
for i in range(a,((N+1)//10+1)):
  if N%i==0:
    r=N//i
    print(max(len(str(i)),len(str(r))))
    exit()

print(len(str(N)))

Submission status: Time Limit Exceeded

Solution code:
import math
 
N=int(input())
 
a=math.ceil(math.sqrt(N))
 
for i in range(a,((N+1)//2+1)):
  if N%i==0:
    r=N//i
    print(max(len(str(i)),len(str(r))))
    exit()
print(len(str(N)))

Submission status: Time Limit Exceeded

Solution code:
def F(a,b):
    a=len(str(a))
    b=len(str(b))-2#float型のため
    return a if a>b else b
n=int(input())
o=[]
k=100000000
c=0
m=10000000000
for i in range(1,n):
    if c>0:
        c-=1
        continue
    s=n/i
    if s.is_integer():
        k=F(i,s)
        o.append(k)
        if k>m:
            break
        m=k
        i=int("1"+"0"*len(str(i)))-i#iを次の位にする
try:
    print(min(o))
except:
    print(1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans1 = 0

A = '1'
B = str(N)

if len(A)>=len(B):
    ans = len(A)
else:
    ans = len(B)
    
for i in range(2,N+1):
    A = i
    if N%A==0:
        B = int(N / A)
        A = str(A)
        B = str(B)
        #print(A, B)
        if len(A)>=len(B):
            ans1 = len(A)
        else:
            ans1 = len(B)
        if ans1 <= ans:
            ans = ans1
    if len(str(A))==len(str(B)):
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

N=int(input())

a=math.ceil(math.sqrt(N))

for i in range(a,((N+1)//2+1)):
  if N%i==0:
    r=N//i
    print(max(len(str(i)),len(str(r))))
    exit()
print(len(str(N)))

Submission status: Time Limit Exceeded

Solution code:
import math

N=int(input())

a=math.ceil(math.sqrt(N))

for i in range(a,N+1):
  if N%i==0:
    r=N//i
    print(max(len(str(i)),len(str(r))))
    exit()

Submission status: Time Limit Exceeded

Solution code:

DEBUG = False
N = int(input())

# if N == 1:
#     print(1)
#     exit()

divisors = []

tmp = N
for i in range(2, N):#int(N**0.5)+1):
    while tmp % i == 0:
        tmp //= i
        divisors.append(i)
if tmp != 1:
    divisors.append(tmp)

if DEBUG:
    print(divisors)

A = 1
B = 1
while divisors:
    x = divisors.pop()
    if A > B:
        B *= x
    else:
        A *= x

if DEBUG:
    print("A: {}, B: {}".format(A, B))

print(max(len(str(A)), len(str(B))))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
f=[]
for a in range(1,n+1):
    if n%a==0:
        b=n//a
        f.append(max(len(str(a)),len(str(b))))
print(min(f))

Submission status: Time Limit Exceeded

Solution code:
c = 12
n = int(input())

result = []
for a in range(1,n+1):
    counta = 0
    countb = 0
    if n%a == 0:
        b = n/a
        while a >= 1:
            a = a/10
            counta += 1
        while b >= 1:
            b = b/10
            countb += 1
        if c >= counta + countb:    
            c = counta + countb
            result.append(max([counta,countb]))
            

print(min(result))

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
n = math.floor(math.sqrt(N))
i=0
while True:
  if N%(n+i) == 0:
    print(len(str((n+i))))
    exit()
  else: i+=1

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

min_length = -1
for i in range(int(math.sqrt(N))):
    for j in range(i + 1):
        A = j + 1
        if N % A == 0:
            B = int(N / A)
            len_a = len(str(A))
            len_b = len(str(B))
            length = len_a if len_a >= len_b else len_b
            if min_length == -1 or length < min_length:
                # print("len:{}, A:{}, B:{}".format(length, A, B))
                min_length = length
print(min_length)

Submission status: Time Limit Exceeded

Solution code:
def main():
    # 入力
    s = input()

    x = len(s)
    limit = int(x/2) if x % 2 == 0 else int(x/2)+1

    n = int(s)

    min_l = 10

    # ccc = 0
    for i in range(1, n+1):
        # ccc += 1
        if n % i != 0:
            continue
        il = len(str(i))
        if il == min_l:
            break
        j = int(n / i)

        jl = len(str(j))
        f = max(il, jl)
        if f < min_l:
            min_l = f
        if min_l == limit or il == jl or il > jl:
            break


    # print(ccc)
    print(min_l)


main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    # 入力
    n = int(input())

    min_l = 10

    # ccc = 0
    for i in range(1, n+1):
        # ccc += 1
        if n % i != 0:
            continue
        il = len(str(i))
        if il == min_l:
            break
        j = int(n / i)

        jl = len(str(j))
        f = max(il, jl)
        if f < min_l:
            min_l = f
        if il == jl or il > jl:
            break


    # print(ccc)
    print(min_l)


main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    # 入力
    n = int(input())

    min_l = 10

    # ccc = 0
    for i in range(1, n+1):
        # ccc += 1
        if n % i != 0:
            continue
        il = len(str(i))
        if il > min_l:
            break
        j = int(n / i)

        jl = len(str(j))
        f = max(il, jl)
        if f < min_l:
            min_l = f
        if il == jl or il > jl:
            break


    # print(ccc)
    print(min_l)


main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    # 入力
    n = int(input())

    min_l = 10

    # ccc = 0
    for i in range(1, n+1):
        il = len(str(i))
        if il > min_l:
            break
        # ccc += 1
        if n % i != 0:
            continue
        j = int(n / i)

        jl = len(str(j))
        f = max(il, jl)
        if f < min_l:
            min_l = f
        if il == jl or il > jl:
            break


    # print(ccc)
    print(min_l)


main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    # 入力
    n = int(input())

    min_l = 10

    for i in range(1, n+1):
        if n % i != 0:
            continue
        j = int(n / i)

        il = len(str(i))
        jl = len(str(j))
        f = max(il, jl)
        if f < min_l:
            min_l = f
        if il > min_l or il == jl or il > jl:
            break

    print(min_l)


main()