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) - 入门与工具简介 上篇文章 ...
随机推荐
- postman之上传文件
前言 小伙伴们在日常工作中有没测试过上传文件的接口呢?那么怎么用postman测试上传文件的接口呢?下面我们一起来学习吧! 需求:(1)上传接口地址:http://localhost:8080/pin ...
- PHP在程序处理过程中动态输出内容
在安装discuz或其他一些开源产品的时候,在安装数据库时页面上的安装信息都是动态输出出来的,主要通过php两个函数来实现的, flush();ob_flush(); 代码如下 <html xm ...
- Flutter报错 Waiting for another flutter command to release the startup lock...
Waiting for another flutter command to release the startup lock… 异常解决 平时我们在开发flutter过程中,在执行flutter p ...
- C#在窗体中按下鼠标键拖动窗体
[DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); [DllImport ...
- pytorch之 activation funcion
import torch import torch.nn.functional as F from torch.autograd import Variable import matplotlib.p ...
- 【转载】Java的Vector,ArrayList,LinkedList
首先看这两类都实现List接口,而List接口一共有三个实现类,分别是ArrayList.Vector和LinkedList.List用于存放多个元素,能够维护元素的次序,并且允许元素的重复.3个具体 ...
- Arm开发板+Qt学习之路-multiple definition of
问题描述:在一个头文件a.h中定义一些变量x,在其他.c文件中(b.c,c.c)要用到.用一般的全局变量的方法,编译时总是提示error:multiple definition of x 问题分析:o ...
- Arm开发板+Qt学习之路-论can网通讯受log日志的影响
日期:2016-05-25 最近开发过程中发现一个问题,使用两个开发板进行can网通讯,按照经验来说,通讯的速度应该是很快的,项目中将接口的超时时间设置为100ms,在某种情境下,会在短时间内发送多次 ...
- Java的引用类型的内存分析
一. jdk的内存:jdk的bin目录常见命令 1. javac.exe:编译java源代码的,生成java字节码文件(*.class) 2. java.exe:启动一个jvm,来运行指定class字 ...
- jq模糊匹配(qq:2798641729)
图灵学院--Java高级架构师-互联网企业级实战VIP课程(价值6380)(qq:1324981084) jq是一般程序员在前台开发的时候都会使用的技术,其中模糊匹配查询在动态添加标签的时候经常用到, ...