public class Solution
{
public IList<int> PowerfulIntegers(int x, int y, int bound)
{
var list = new List<int>();
for (int i = ; i < bound; i++)
{
for (int j = ; j < bound; j++)
{
var num =
Math.Pow((double)x, (double)i)
+
Math.Pow((double)y, (double)j);
if (num <= bound)
{
list.Add((int)num);
}
else
{
if (j == )
{
return list.Distinct().OrderBy(a => a).ToList();
}
else
{
break;//换行
}
}
}
}
return list.Distinct().OrderBy(a => a).ToList();
}
}

leetcode970的更多相关文章

  1. [Swift]LeetCode970.强整数 | Powerful Integers

    Given two non-negative integers x and y, an integer is powerful if it is equal to x^i + y^j for some ...

  2. LeetCode970. 强整数

    问题:970. 强整数 用户通过次数0 用户尝试次数0 通过次数0 提交次数0 题目难度Easy 给定两个非负整数 x 和 y,如果某一整数等于 x^i + y^j,其中整数 i >= 0 且  ...

  3. Leetcode970. Powerful Integers强整数

    给定两个非负整数 x 和 y,如果某一整数等于 x^i + y^j,其中整数 i >= 0 且 j >= 0,那么我们认为该整数是一个强整数. 返回值小于或等于 bound 的所有强整数组 ...

随机推荐

  1. LeetCode——7. Reverse Integer

    一.题目链接:https://leetcode.com/problems/reverse-integer/ 二.题目大意: 给定一个整数,要求反转该整数之后再返回:如果归返回的整数超过了int型整数的 ...

  2. MyBatis 值的传递

    1.值的传递 - Map传值 可以通过对象获取Map传递值,在配置文件中通过 #{} 或 ${} 进行应用 查询30-40岁的用户 <!-- 值的传递 - Map传值 --> <se ...

  3. Java学习---流与文件

    实验10  流与文件操作 一.实验目的 理解和掌握JAVA程序中实现输入/输出的技术和有关的类与方法. 二.实验要求 掌握File类常用的方法 掌握标准数据流及Scanner类的应用. 掌握文件输入输 ...

  4. JDK类集框架实验(ArrayList,LinkedList,TreeSet,HashSet,TreeMap,HashMap)

        ArrayList import java.util.ArrayList; public class C8_3 { public static void main(String[] args) ...

  5. Java中的局部变量、成员变量和静态变量

    直接看代码 public class Variable { // 静态变量,属于类的变量,且用关键字static声明,不属于实例,虽然可以通过实例来调用,但是不建议 private static in ...

  6. intent--Activity之间数据传递之Intent数据传递

    intent传值: 4,intent传集合 3,intent传对象, 2,传递后有返回值的情况:当需要从目标Activity回传数据到原Activity时,可以使用上述方法定义一个新的Intent来传 ...

  7. android判断adb调试是否打开及代码跳转到开发者选项界面

    boolean enableAdb = (Settings.Secure.getInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0) &g ...

  8. Android给TextView设置多个字体颜色

    效果如下:

  9. SSM 项目整合

    SSM整合:spring + springmvc + mybatis 1.1 生成Maven项目:ar_ssm 1.2 添加jar包 <dependencies> <!-- 单元测试 ...

  10. C# DataGirdview手动添加数据,导出txt文件并自动对齐

    //DataGirdview手动添加数据 private void btnDataGirdView_Click(object sender,EventArgs e) {       dataGridV ...