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 ...
随机推荐
- 【scala】迭代器
如何访问集合呢?我们首先想到的是使用for循环来访问,还有一种方法是通过迭代器来访问. 在Scala中,迭代器(Iterator)不是一个集合,但是,提供了访问集合的一种方法. 迭代器包含两个基本的操 ...
- 【51nod-1596】搬货物
现在有n个货物,第i个货物的重量是 2wi .每次搬的时候要求货物重量的总和是一个2的幂.问最少要搬几次能把所有的货物搬完. 样例解释: 1,1,2作为一组. 3,3作为一组. Input 单组测试数 ...
- LeetCode OJ:Add Two Numbers (相加链表之数)
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...
- 使用ORC识别图片的文字
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- struts2逻辑视图类型汇总与解释(转)
在struts2框架中,当action处理完之后,就应该向用户返回结果信息,该任务被分为两部分:结果类型和结果本身. 结果类型提供了返回给用户信息类型的实现细节.结果类型通常在Struts2中就已预定 ...
- android 进制转换方法
import android.util.Log; public class CommandHelper { public static String intToHexString(int value) ...
- leetcode_sql_4,196
196. Delete Duplicate Emails Write a SQL query to delete all duplicate email entries in a table name ...
- ExpressionTree,Emit,反射
ExpressionTree,Emit,反射 https://www.cnblogs.com/7tiny/p/9861166.html [前言] 前几日心血来潮想研究着做一个Spring框架,自然地就 ...
- 微型 Python Web 框架: Bottle
微型 Python Web 框架: Bottle 在 19/09/11 07:04 PM 由 COSTONY 发表 Bottle 是一个非常小巧但高效的微型 Python Web 框架,它被设计为仅仅 ...
- 剑指offer-第四章解决面试题的思路(栈的压入和弹出序列)
题目:输入两个整数序列,第一个序列表示栈的压入序列,请判断第二个序列是否为弹出序列. 思路:定义两个指针sPush和sPop分别指向两个整数序列的开头,借助一个辅助的栈,将第一个序列的数据依次压入栈中 ...