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())

anss = []
for n in range(1,math.ceil(N**0.5)):
	if N % n == 0:
		anss.append(max(len(str(n)),len(str(N//n))))

if len(anss) == 0:
	anss.append(1)
		
print(min(anss))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

anss = []
for n in range(1,math.ceil(N**0.5)):
	if N % n == 0:
		anss.append(max(len(str(n)),len(str(N//n))))
else:
	anss.append(1)
		
print(min(anss))

Submission status: Wrong Answer

Solution code:
import math

n=int(input())
l=len(str(n))
m=math.floor(n**0.5)
max=1
for i in range(1,m):
    if n%i==0:
        max=i
ans=len(str(n//max))
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=1
for i in range(1,int(n**0.5)):
    if n%i==0:
        a=i
print(max(len(str(a)),len(str(n//a))))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 17:48:45 2019

@author: yuta
"""
import math
N = int(input())

def main(n):
    sqrt_n = math.sqrt(n)
    min_keta = len(str(n))
    for i in range(1,(int(sqrt_n)+1)):
        if n % i == 0:
            c = len(str(max(i,n/i)))
            if c < min_keta:
                min_keta = c
    print(min_keta)
main(N)

Submission status: Wrong Answer

Solution code:
N = int(input())
rootn = int(N**0.5) +1
A = range(1, rootn)
min_digits = 11
for i in A:
    if (N % i) == 0:
        B = N // i
        p, q =len(str(A)), len(str(B))
        if (p > q) and p < min_digits:
            min_digits = p
        elif (p <= q) and q < min_digits:
            min_digits = q
print(min_digits)

Submission status: Wrong Answer

Solution code:
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N+1):
    if a*a > N:
        break
    if (N % a) != 0:
        continue
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Submission status: Wrong Answer

Solution code:
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N+1):
    if (N % a) != 0:
        continue
    if a*a > N:
        break
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Submission status: Wrong Answer

Solution code:
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N+1):
    if (N % a) != 0:
        continue
    if a*a >= N:
        break
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Submission status: Wrong Answer

Solution code:
import math
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N):
    if (N % a) != 0:
        continue
    if a*a >= N:
        break
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Submission status: Wrong Answer

Solution code:
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
n = int(N**0.5)
result = len(str(N))
for a in range(1, n):
    if n % a != 0:
        continue
    b = n / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Submission status: Wrong Answer

Solution code:
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
n = int(N**0.5)
result = len(str(N))
for a in range(1, n):
    if N % a != 0:
        continue
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Submission status: Wrong Answer

Solution code:
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
n = int(N**0.5)
result = len(str(N))
for a in range(1, n+1):
    if N % a != 0:
        continue
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Submission status: Wrong Answer

Solution code:
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
n = int(N**0.5)
for i in range(1, n+1):
    for j in range(1, n+1):
        if i*j == N:
            print (f(i, j))
            exit()

Submission status: Wrong Answer

Solution code:
def f(n):
    rootn = int((N+1)**0.5)
    A = range(1, rootn)
    min_output = 11
    for i in A:
        if (N % i) == 0:
            ilen = len(str(i))
            B = len(str(N//i))
            if ilen < B:
                if min_output > B:
                    min_output = B
            else:
                if min_output > ilen:
                    min_output = ilen
    return min_output
N = int(input())
print(f(N))

Submission status: Wrong Answer

Solution code:
n=int(input())
ans = len(str(n))
l = [ i for i in range(1,n+1) if i*i < n]
for a in l[::-1]:
    if n % a == 0:
        print( max(len(str(a)),len(str(int(n / a)))))
        break

Submission status: Wrong Answer

Solution code:
n=int(input())
ans = len(str(n))
l = [ i for i in range(1,n+1) if i*i < n]
for a in l:
    if n % a == 0:
        if ans > max(len(str(a)),len(str(int(n / a)))):
            ans = max(len(str(a)),len(str(int(n / a))))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

res = prime_factor(N)

result = 10 ** 10
for i in range(1, N):
    if N%i == 0:
        result = min(result, max(len(str(i)), len(str(N//i))))
    if i*i >= N:
        break


print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

res = prime_factor(N)

tmp = 1
tmp2 = N
for i in range(len(res)):
    count = tmp2
    if len(str(tmp)) >= len(str(tmp2)):
        break
    tmp2 = tmp2//res[i]
    tmp *= res[i]
    
print(len(str(count)))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

res = prime_factor(N)

tmp = 1
tmp2 = N
for i in range(len(res)):
    if len(str(tmp)) > len(str(tmp2)):
        break
    count = tmp2
    tmp2 = tmp2//res[i]
    tmp *= res[i]
    
print(len(str(count)))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
def f(n):
  g = float('inf')
  for i in [j for j in range(1,math.ceil(n**0.5)) if n%j == 0]:
    if g > len(str(max(i,n//i))):
      g = len(str(max(i,n//i)))
    if g == float('inf'):
        g = 1
  return g
print(f(n))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
def f(n):
  g = float('inf')
  for i in [i for i in range(1,math.ceil(n**0.5)) if n%i == 0]:
    if g > len(str(max(i,n//i))):
      g = len(str(max(i,n//i)))
    if g == float('inf'):
        g = 1
  return g
print(f(n))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
def f(n):
  g = float('inf')
  for i in [i for i in range(1,math.ceil(n**0.5)) if n%i == 0]:
    if g > len(str(max(i,n//i))):
      g = len(str(max(i,n//i)))
  return g
print(f(n))

Submission status: Wrong Answer

Solution code:
n = int(input())
def f(n):
  g = float('inf')
  for i in range(1,n//2+1):
    if n % i == 0:
      if g > max(len(str(i)),len(str(n//i))):
        g = max(len(str(i)),len(str(n//i)))
  return g
print(f(n))

Submission status: Wrong Answer

Solution code:
n = int(input())
def f(n):
  g = float('inf')
  for i in range(1,n//2+1):
    if n % i == 0:
      if g > len(str(i))+len(str(n//i)):
        g = len(str(i))+len(str(n//i))
  return g
print(f(n))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
if N <= 9:
    ans = 1
else:
    ans = 11
for n in range(1, int(math.sqrt(N))):
    if N % n == 0:
        # print(n)
        f = max(len(str(n)), len(str(int(N/n))))
        if f < ans:
            # print("f: %d"%f)
            ans = f
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
ans = 11
for n in range(1, int(math.sqrt(N))):
    if N % n == 0:
        # print(n)
        f = max(len(str(n)), len(str(int(N/n))))
        if f < ans:
            # print("f: %d"%f)
            ans = f
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
N_max = math.floor(pow(N, 0.5))

ans = math.floor(math.log10(N))

for i in range(1, N_max+1):
    if N % i == 0:
        M = N / i
        digI = math.floor(math.log10(i)) + 1
        digM = math.floor(math.log10(M)) + 1
        if digI >= digM:
            score = digI
        else:
            score = digM

        if score <= ans:
            ans = score

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
larger = 0
for i in range(1, N):
    if i*i > N:
        break
    if N % i == 0:
        larger = N // i

ans = 0
while larger > 0:
    ans += 1
    larger //= 10
print(ans)

Submission status: Wrong Answer

Solution code:
import math

#入力
N = int(input())
minF = 100 #Fの最小値

#A = 1のとき
F = int(math.log10(N)) +1
if F < minF:
    minF = F
    
for A in range(2,int(math.sqrt(N))):
    #AがBの約数でなかったら飛ばす
    if N % A == 0:
        B = N / A
        #F = culculate_F(A,B)
        F = int(math.log10(B)) + 1
        #Fがこれまでで最小ならminFを更新
        if F < minF:
            minF = F

print(minF)

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit; setrecursionlimit(10**9)
N = int(input())

def factorize(n):
    # NOTE: if n == 1, return []
    if n < 1:
        raise Exception('Invalid input: n = {}'.format(n))
    i = 2
    ret = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret.append(i)
        i += 1
    if n > 1:
        ret.append(n)
    return ret

A = factorize(N)
l = len(A)

def res(i, B, C):
    if i >= l:
        val = 1
        for b in B:
            val *= b
        C.append(max(len(str(val)), len(str(N//val))))
        return None
    B.append(A[i])
    res(i+1, B, C)
    B.pop()
    res(i+1, B, C)
    return C

if N == 1:
    print(1)
else:
    C = res(0, [], [])
    min(C)