Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Tags
- 강화학습
- GNN
- Recursion
- 소프티어
- 수치최적화
- Hybrid A star
- MDP
- C++
- 정적라이브러리
- OSQP
- 백준
- Motion Planning
- CUDA
- path planning
- Dubins Path
- self driving car
- 경로생성
- Graph Neural Network
- Frenet Coordinate
- 동적라이브러리
- C
- solver
- DynamicProgramming
- 선형대수
- Leetcode
- GIT
- autonomous vehicle
- CPP
- PathPlanning
- 공유라이브러리
Archives
- Today
- Total
Swimmer
[LeetCode] 728. Self Dividing Numbers, C++ 본문
Solution
- Calculate digit, Check integer is divable by all digits
class Solution {
public:
bool IdSelfDividingNumber(int n)
{
int k = 10;
int a = n;
for (int i = 1; i != 5; ++i)
{
int digit = a % k;
if (digit == 0)
{
return false;
}
else if (n % digit != 0)
{
return false;
}
else
{
// Do Nothing
}
a = a / k;
if (a == 0)
{
return true;
}
}
return true;
}
vector<int> selfDividingNumbers(int left, int right) {
vector<int> res;
for (int i = left; i < (right + 1); ++i)
{
if (IdSelfDividingNumber(i) == true)
{
res.push_back(i);
}
else
{
// DO Nothing
}
}
return res;
}
};
'코딩 문제' 카테고리의 다른 글
[LeetCode] 771, Jewels and Stones (0) | 2023.02.14 |
---|---|
[LeetCode] 1720 Decode XORred Array (0) | 2023.01.29 |
[LeetCode] 2032. Two Out of Three, C++ (0) | 2023.01.25 |
[Leet Code] 231. Power of Two, C++ (0) | 2023.01.17 |
[LeetCode] 2331. Evaluate Boolean Binary Tree, cpp (0) | 2023.01.10 |
Comments