Maximize Number of Nice Divisors

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class Solution:
    def maxNiceDivisors(self, primeFactors: int) -> int:
        M = 10**9 + 7
        if primeFactors <= 3: 
            return primeFactors
        if primeFactors % 3 == 0: 
            return pow(3, primeFactors //3, M)
        if primeFactors % 3 == 1: 
            return (pow(3, (primeFactors - 4) // 3, M) * 4) % M
        return (2 * pow(3, primeFactors // 3, M)) % M