LeetCode 728. 自除数
题目链接:https://leetcode-cn.com/problems/self-dividing-numbers/
给定上边界和下边界数字,输出一个列表,列表的元素是边界(含边界)内所有的自除数。
示例 1:
输入:
上边界left = 1, 下边界right = 22
输出: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]
注意:
每个输入参数的边界满足 1 <= left <= right <= 10000。
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* selfDividingNumbers(int left, int right, int* returnSize){
int* a=calloc(right-left+,sizeof(int));
int i=left;
int t=;
while(i<=right){
if(i<){
a[t++]=i;
}else{
int flag=;
int x=i;
while(x){
if(x%==){
flag=;
break;
}else if(i%(x%)!=){
flag=;
break;
}
x/=;
}
if(flag) a[t++]=i;
}
i++;
}
*returnSize=t;
return a;
}
LeetCode 728. 自除数的更多相关文章
- Java实现 LeetCode 728 自除数(暴力)
728. 自除数 自除数 是指可以被它包含的每一位数除尽的数. 例如,128 是一个自除数,因为 128 % 1 == 0,128 % 2 == 0,128 % 8 == 0. 还有,自除数不允许包含 ...
- C# 刷遍 Leetcode 面试题系列连载(3): No.728 - 自除数
前文传送门: C#刷遍Leetcode面试题系列连载(1) - 入门与工具简介 C#刷遍Leetcode面试题系列连载(2): No.38 - 报数 系列教程索引 传送门:https://enjoy2 ...
- 力扣(LeetCode)728. 自除数
自除数 是指可以被它包含的每一位数除尽的数. 例如,128 是一个自除数,因为 128 % 1 == 0,128 % 2 == 0,128 % 8 == 0. 还有,自除数不允许包含 0 . 给定上边 ...
- LeetCode - 728. Self Dividing Numbers
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is ...
- LeetCode 728 Self Dividing Numbers 解题报告
题目要求 A self-dividing number is a number that is divisible by every digit it contains. For example, 1 ...
- [LeetCode] 728. Self Dividing Numbers_Easy tag: Math
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
- C#刷遍Leetcode面试题系列连载(1) - 入门与工具简介
目录 为什么要刷LeetCode 刷LeetCode有哪些好处? LeetCode vs 传统的 OJ LeetCode刷题时的心态建设 C#如何刷遍LeetCode 选项1: VS本地Debug + ...
- C#刷遍Leetcode面试题系列连载(2): No.38 - 报数
目录 前言 题目描述 相关话题 相似题目 解题思路: 运行结果: 代码要点: 参考资料: 文末彩蛋 前言 前文传送门: C# 刷遍 Leetcode 面试题系列连载(1) - 入门与工具简介 上篇文章 ...
随机推荐
- 提升命令行效率的Bash快捷键
转自:http://linuxtoy.org/archives/bash-shortcuts.html 生活在 Bash shell 中,熟记以下快捷键,将极大的提高你的命令行操作效率. 大部分对其他 ...
- 修改定时清理 /tmp 目录下的文件
初衷 默认系统是超过 30 天不访问的文件自动清除的,但是有时候硬盘用得紧可以考虑修改周期 设置方法 编辑配置文件:vim /etc/cron.daily/tmpwatch #! /bin/sh fl ...
- mysql中大数据表alter增加字段报错:"1034 Incorrect key file for table 'table_name'; try to repair it"
mysql中大数据表alter增加字段报错:"1034 Incorrect key file for table 'table_name'; try to repair it" 现 ...
- [Python]JavaScript VS Python 函数
js function 相当于 python def js语句结束符; python为缩进符 JavaScript /*定义*/ function 函数名(参数1,参数2,参数3...){ 函数体 } ...
- java连接Oracle数据库,从ResultSet中提取数据出现java.sql.sqlException结果集已耗尽
出现错误的原因是ResultSet中并没有任何东西,再调用next()方法就会出错,原因可能是oracle创建用户,表没有提交,commit即可
- Windows安装MySQL免安装版
安装环境: win7 64位 IP地址:192.168.2.37 防火墙已经关闭 一.安装MySQL5.7.14免安装版 1.解压文件 2.新建my.ini文件 data文件夹自动生成 my.ini里 ...
- centos7上安装docker社区版
container(容器) docker(集装箱) 容器的优点 1. 启动速度快 2. 节省资源 3. 兼容性高 保证机器正常上网 #ping www.baidu.com CPU需要支持虚拟化 # g ...
- JMeter函数助手中Random函数详解
1.__Random函数的生成 The minimum value allowed for a range of values:一个范围内允许的最小值 The maximum value allowe ...
- 网易MuMu模拟器不显示Menu(菜单)键的解决办法
解决方法一: 前提:需要一个键盘 步骤: 1.直接按下键盘上的Menu键. 解决方法二: 前提:需要Root之后的文件浏览器 步骤: 1.在文件管理器中打开 /System 文件夹: 2.复制 bui ...
- Java虚拟机——JVM
一.JVM整体架构 1.JVM(Java虚拟机):指以软件的方式模拟具有完整硬件系统功能.运行在一个完全隔离环境中的完整计算机系统,是物理机的软件实现.常用的虚拟机有VMWare.Virtual Bo ...