leetcode728
vector<int> selfDividingNumbers(int left, int right) {
vector<int> V;
for (int i = left; i <= right; i++)
{
//将数字分解
int temp = i;
if (i >= && i <= )
{
V.push_back(i);
continue;
}
bool tag = true;
while (temp != )
{
int a = temp / ;
int b = temp % ;
if (b == )
{
tag = false;
break;
}
if (i%b != )
{
tag = false;
break;
}
temp = a;
}
if (tag)//此值可以自除
{
V.push_back(i);
}
}
return V;
}
leetcode728的更多相关文章
- [Swift]LeetCode728. 自除数 | Self Dividing Numbers
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is ...
- LeetCode728. 自除数
自除数 是指可以被它包含的每一位数除尽的数. 例如,128 是一个自除数,因为 128 % 1 == 0,128 % 2 == 0,128 % 8 == 0. 还有,自除数不允许包含 0 . 给定上边 ...
- Leetcode728.Self Dividing Numbers自除数
自除数 是指可以被它包含的每一位数除尽的数. 例如,128 是一个自除数,因为 128 % 1 == 0,128 % 2 == 0,128 % 8 == 0. 还有,自除数不允许包含 0 . 给定上边 ...
- C# 刷遍 Leetcode 面试题系列连载(3): No.728 - 自除数
前文传送门: C#刷遍Leetcode面试题系列连载(1) - 入门与工具简介 C#刷遍Leetcode面试题系列连载(2): No.38 - 报数 系列教程索引 传送门:https://enjoy2 ...
随机推荐
- ios上传图片遇见了一个TimeoutError(DOM Exception 23)异常
TimeoutError(DOM Exception 23):The operation timed out 百度了下,没发现解决办法
- R-一页多图
https://blog.csdn.net/ailsa__/article/details/45932753
- 专业工具软件PCB板打印说明
专业工具软件PCB板打印说明 请注意PCB板打印不要直接截图,如下方式是不正确的: 这样在打印为黑白图片时,元器件之间的连线无法看清. 应采用如下模式: ~End~
- CentOS修改系统的默认启动模式为命令号界面
CentOS在安装桌面之后,将图形界面设置为默认模式,给PC内存带来较大压力,所以希望修改系统的默认启动模式为命令号界面,而不启动图形界面.方法如下: 1.以 root用户登录系统:或者 用su切换到 ...
- freemarket使用自定义标签 注解【项目实际使用】
页面达到效果 [主html页面代码] <!-- 合作单位 版块 -->[#include 'inc_project_succ_coo.html'/]['inc_project_succ_c ...
- 在C#获取麦克风输入的声音的波形图
怎么获取声音波动的频率,在网上找来一些这方面的资料: DirectX的 DirectSound http://zhidao.baidu.com/question/448587955.html http ...
- input type="file" accept="image/*"上传文件慢的问题解决办法
相信大家都写过<input type="file" name="file" class="element" accept=" ...
- Android的移动存储解决方案之SharedPreferences
搞Android有一段时间了,但是并没写过有关Android的博客,今天给大家介绍一下SharedPreferences. 使用SharedPreferences保存key-value对的步骤如 ...
- linux下安装ZipArchive扩展和libzip扩展
在项目开发的时候,由于要下载多个录音文件,我就需要打包下载这个功能 学习源头: https://www.landui.com/help/show-8079 https://www.aliyun.com ...
- 菜鸟天天不懂,那就天天敲它。。。还不懂。。。JAVA数组比较大小。
package com.aini; import java.util.Scanner; //操...为什么数组的大小比较我硬是搞不懂,比较大小依然放在for循环里... //从键盘输入一组数据,并输出 ...