codingTest

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 1704번 Determine if String Halves Are Alike

문제 출처:https://leetcode.com/problems/determine-if-string-halves-are-alike/ Determine if String Halves Are Alike - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 코드는 다음과 같습니다: class Solution { public: bool halvesAreAlike(string s) { size_t len = s.length() ; int cnt_l = 0, cnt_r = 0..

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 367번 Valid Perfect Square

문제 출처:https://leetcode.com/problems/valid-perfect-square/ 해당 문제는 이전에 풀었던 문제와 비슷하게 적용가능합니다. https://coding-leaf.tistory.com/117 Leetcode 문제 69번 Sqrt(x) 문제 출처:https://leetcode.com/problems/sqrtx/ Sqrt(x) - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next i.. coding-leaf.tistory.com 코드는 다음과 같습니다: class Soluti..

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 728번 Self Dividing Numbers

문제 출처:https://leetcode.com/problems/self-dividing-numbers/ Self Dividing Numbers - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 분석 각 숫자를 이루고 있는 원소들로 나누어서 나머지가 없는 수를 self dividing number라고 하나봅니다. 주어진 Input left와 right 사이의 모든 숫자에 대해서 self dividing number를 구하는 문제입니다. 예를 들어 128이라..

알고리즘 문제풀이/[C++] Codeground

Codeground 문제 1번 숫자 골라내기

간단하게 XOR에 대한 문제입니다. 0과 다른 숫자가 XOR를 한다면 0이 그 숫자로 바뀌게 될 것이고 나머지는 비트연산으로 인해 원하는 값이 출력되게 됩니다. 비트 연산자 AND a & b 둘 다 '참' 일 경우 1 을 반환한다. OR a | b 둘 중 하나라도 '참'인 경우 1을 반환한다. XOR a ^ b 둘 중 하나만 '참'인 경우 1을 반환한다. 코드는 다음과 같습니다: #include using namespace std; int Answer; int main(int argc, char** argv){ int T, test_case; cin >> T; for(test_case = 0; test_case > ..

알고리즘 문제풀이/[C++] Baekjoon

Baekjoon 문제 5355번 화성 수학

문제 출처:https://www.acmicpc.net/problem/5355 5355번: 화성 수학 겨울 방학에 달에 다녀온 상근이는 여름 방학 때는 화성에 갔다 올 예정이다. (3996번) 화성에서는 지구와는 조금 다른 연산자 @, %, #을 사용한다. @는 3을 곱하고, %는 5를 더하며, #는 7을 빼는 연산 www.acmicpc.net 문제 분석 저는 처음에 연산 우선도도 따라야는 문제인줄 알았으나 예제를 살펴본 결과 그냥 앞에서부터 연산하는 것입니다. 따라서 크게 복잡하게 생각하지 않고 주어진 인풋에 따라 더해주고 곱해주고 빼주면 되는 문제였습니다. 다만 각 라인별로 몇개의 input이 주어질지 모르기에 line by line으로 값을 받아와야 합니다. 코드는 다음과 같습니다: #include ..

gurcks8989
'codingTest' 태그의 글 목록 (7 Page)