leetcode970
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的更多相关文章
- [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 ...
- LeetCode970. 强整数
问题:970. 强整数 用户通过次数0 用户尝试次数0 通过次数0 提交次数0 题目难度Easy 给定两个非负整数 x 和 y,如果某一整数等于 x^i + y^j,其中整数 i >= 0 且 ...
- Leetcode970. Powerful Integers强整数
给定两个非负整数 x 和 y,如果某一整数等于 x^i + y^j,其中整数 i >= 0 且 j >= 0,那么我们认为该整数是一个强整数. 返回值小于或等于 bound 的所有强整数组 ...
随机推荐
- Git将本地库内容推送到远程
本地库与远程库的交互 1 .将本地库的内容推送到远程库 A.创建一个本地仓库 $ mkdir gitdemo B.初始化本地仓库 $ git init C.项目根目录下创建 .gitignore 文件 ...
- IDEA创建一个Mybatis逆向工程
Mybatis逆向工程简介: MyBatis Generator (MBG) 是一个Mybatis的代码生成器 MyBatis 和 iBATIS. 他可以生成Mybatis各个版本的代码,和iBATI ...
- 在Python中进行自动化单元测试的教程
From: https://www.jb51.net/article/64119.htm 一.软件测试 大型软件系统的开发是一个很复杂的过程,其中因为人的因素而所产生的错误非常多,因此软件在开发过程必 ...
- 解决搜狗高速模式及设置页面打不开的问题DisableFeature.reg
搜狗浏览器安装问题1.安装的时候要选择自定义安装,去掉参加用户体验计划的√,否则可能安装不上.2.搜狗sogou_explorer_7.0_0111.exe,设置页面se://settings/?ca ...
- SecureCRT & SecureFx 绿色破解版
租了腾讯云的服务器,是 ubuntu 版的,需要用到 SecureCRT 工具来远程链接,但是连接的只是控制台,只能输入命令操作,如果要下载文件什么的,就很麻烦,这时可以使用 SecureFx 来传输 ...
- php的语句
1.php流程语句 1.php代码执行从上到下 2.条件语句 if else 和 switch 案例: $name=56; if($name>56) echo "hello world ...
- HDOJ 2003 求绝对值
#include<cstdio> #include<cmath> int main() { double a; while (scanf_s("%lf", ...
- win10以上系统设定PPTP自动拨号
:bohaorasdial adsl 123 123if not %errorlevel% == 0 goto :bohaoexit rasdial adsl 123 123 rasdial是开始拨号 ...
- [UE4]下拉菜单
- @postconstruct初始化的操作(转载)
原文地址:https://www.cnblogs.com/qingruihappy/p/7861623.html 从Java EE 5规范开始,Servlet中增加了两个影响Servlet生命周期的注 ...