import math


def is_perfect_optimized(num: int) -> bool:
    """
        Calculates if a number is perfect in a non-naive way. This function
        takes into account:
        - Divisors present themselves in pairs when calculating.
        - The quotient can also count as a divisor
        - With this approach one only need go up to sqrt(num).
        - Can store partial sum instead of occupying memory with list of
          divisors.

        With this approach we would obtain:
        - Temporal Complexity => O(√n)
        - Spacial Complexity => O(1)
    """
    sum_divisors = 0

    for current in range(1, int(math.sqrt(num))+1):
        # Is divisor of the number.
        if num % current == 0:
            sum_divisors += current

            # Quotient may also be a solution.
            if num / current != current:
                sum_divisors += (num // current)

    return num*2 == sum_divisors