Sherlock and The Beast

  • + 0 comments
    def decentNumber(n):
        fives3 = 0
        threes5 = 0
    
        for k in range(n//5+1):
            threes5 = k
            if (n - 5*k) % 3 == 0:
                fives3 = (n - 5*k)//3
                break
        
        if fives3*3 + threes5*5 != n:
            print(-1)
            return
    
        string = '5'*3*fives3 + '3'*5*threes5
        print(string)
        return