码迷,mamicode.com
首页 > 其他好文 > 详细

Leetcode 970. Powerful Integers

时间:2019-03-16 09:47:19      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:def   return   lin   pen   obj   sel   color   solution   style   

Brute Force(暴力)

class Solution(object):
    def powerfulIntegers(self, x, y, bound):
        """
        :type x: int
        :type y: int
        :type bound: int
        :rtype: List[int]
        """
        ans=[]
        
        for i in range(20):
            for j in range(20):
                a=x**i+y**j
                if a<=bound:
                    ans.append(a)
        
        return list(set(ans))

 

Leetcode 970. Powerful Integers

标签:def   return   lin   pen   obj   sel   color   solution   style   

原文地址:https://www.cnblogs.com/zywscq/p/10540582.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!