본문 바로가기

연습장120

Sum of Digits / Digital Root Digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. The input will be a non-negative integer. Examples 16 --> 1 + 6 = 7 942 --> 9 + 4 + 2 = 15 --> 1 + 5 = 6 132189 --> 1 + 3 + 2 + 1 + 8 + 9 = 24 --> 2 + 4 = 6 493193 --> 4 + 9 + 3 + 1.. 2021. 10. 19.
Find the odd int Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. Examples [7] should return 7, because it occurs 1 time (which is odd). [0] should return 0, because it occurs 1 time (which is odd). [1,1,2] should return 2, because it occurs 1 time (which is odd). [0,1,0,1,0] should return 0, because it occurs.. 2021. 10. 19.
Split Strings Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_'). Examples: solution("abc") // should return {"ab", "c_"} solution("abcdef") // should return {"ab", "cd", "ef"} Solution #include #include std::vector solution(const std::.. 2021. 10. 19.
Perimeter of squares in a rectangle The drawing shows 6 squares the sides of which have a length of 1, 1, 2, 3, 5, 8. It's easy to see that the sum of the perimeters of these squares is : 4 * (1 + 1 + 2 + 3 + 5 + 8) = 4 * 20 = 80 Could you give the sum of the perimeters of all the squares in a rectangle when there are n + 1 squares disposed in the same manner as in the drawing: Hint: See Fibonacci sequence Ref: http://oeis.org/A00.. 2021. 10. 19.
곱셈 - 2588 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 128 MB 147702 71489 61686 49.382% 문제 (세 자릿수) × (세 자릿수)는 다음과 같은 과정을 통하여 이루어진다. (1)과 (2) 위치에 들어갈 세 자리 자연수가 주어질 때 (3), (4), (5), (6) 위치에 들어갈 값을 구하는 프로그램을 작성하시오. 입력 첫째 줄부터 넷째 줄까지 차례대로 (3), (4), (5), (6)에 들어갈 값을 출력한다. 출력 첫째 줄부터 넷째 줄까지 차례대로 (3), (4), (5), (6)에 들어갈 값을 출력한다. 입력1 출력1 472 385 2360 3776 1416 181720 Solution https://github.com/anothel/BOJ/blob/main/python/.. 2021. 10. 19.
A/B - 2 - 15792 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 0.5 초 (추가 시간 없음) 512 MB 3812 1068 848 36.520% 문제 두 정수 A와 B를 입력받은 다음, A/B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 2021. 10. 19.
N과 M (8) - 15657 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 8746 7415 6269 85.084% 문제 N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 같은 수를 여러 번 골라도 된다. 고른 수열은 비 내림차순이어야 한다. 길이가 K인 수열 A가 A1 ≤ A2 ≤... ≤ AK-1 ≤ AK를 만족하면, 비 내림차순이라고 한다. 입력 첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) 둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출.. 2021. 10. 19.
N과 M (7) - 15656 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 8875 6936 5609 79.268% 문제 N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 같은 수를 여러 번 골라도 된다. 입력 첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 7) 둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해야 한.. 2021. 10. 19.
N과 M (6) - 15655 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 8651 7403 6002 85.927% 문제 N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 고른 수열은 오름차순이어야 한다. 입력 첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) 둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안 되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해야 .. 2021. 10. 19.
N과 M (5) - 15654 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 12986 9542 7590 73.319% 문제 N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 입력 첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) 둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안 되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해야 한다. 입력1 출력1 입력2 출력.. 2021. 10. 19.
N과 M (4) - 15652 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 21400 17079 13843 79.911% 문제 자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. 1부터 N까지 자연수 중에서 M개를 고른 수열 같은 수를 여러 번 골라도 된다. 고른 수열은 비 내림차순이어야 한다. 길이가 K인 수열 A가 A1 ≤ A2 ≤... ≤ AK-1 ≤ AK를 만족하면, 비 내림차순이라고 한다. 입력 첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안 되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는.. 2021. 10. 18.
N과 M (3) - 15651 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 28270 18527 14154 65.860% 문제 자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. 1부터 N까지 자연수 중에서 M개를 고른 수열 같은 수를 여러 번 골라도 된다. 입력 첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 7) 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안 되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해야 한다. 입력1 출력1 입력2 출력2 입력3 출력3 3 1 1 2 3 4 2 1 1 1 2 1 3 1 4 2 1 2 2 2 3 .. 2021. 10. 18.
N과 M (2) - 15650 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 29576 22302 16255 74.849% 문제 자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. 1부터 N까지 자연수 중에서 중복 없이 M개를 고른 수열 고른 수열은 오름차순이어야 한다. 입력 첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안 되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해야 한다. 입력1 출력1 입력2 출력2 입력3 출력3 3 1 1 2 3 4 2 1 2 1 3 1 4 2 3 2 4 3 .. 2021. 10. 18.
N과 M (1) - 15649 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 512 MB 43880 26840 17938 60.434% 문제 자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. 1부터 N까지 자연수 중에서 중복 없이 M개를 고른 수열 입력 첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) 출력 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안 되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해야 한다. 입력1 출력1 입력2 출력2 입력3 출력3 3 1 1 2 3 4 2 1 2 1 3 1 4 2 1 2 3 2 4 3 1 3 2 3 4 4 1 4.. 2021. 10. 18.
Which are in? Given two arrays of strings a1 and a2 return a sorted array r in lexicographical order of the strings of a1 which are substrings of strings of a2. Example 1: a1 = ["arp", "live", "strong"] a2 = ["lively", "alive", "harp", "sharp", "armstrong"] returns ["arp", "live", "strong"] Example 2: a1 = ["tarp", "mice", "bull"] a2 = ["lively", "alive", "harp", "sharp", "armstrong"] returns [] Notes: Arrays.. 2021. 10. 13.
Row Weights Scenario Several people are standing in a row divided into two teams. The first person goes into team 1, the second goes into team 2, the third goes into team 1, and so on. Task Given an array of positive integers (the weights of the people), return a new array/tuple of two integers, where the first one is the total weight of team 1, and the second one is the total weight of team 2. Notes Array .. 2021. 10. 13.
Simple multiplication This kata is about multiplying a given number by eight if it is an even number and by nine otherwise. Solution int simpleMultiplication(int a) { return a * (a % 2 == 0 ? 8 : 9); } 후기 아침에 출근해서 간단하게 하나 해결해봤다. 곱하기를 하는 함수인데, 짝수이면 8을 홀수이면 9를 곱하라고 한다. 나의 코드를 올리니 이미 많은 다른 사람들도 이렇게 짰더라.. 하나 고민인 것이 있는데 Google C++ Style Guide에서는 삼항 연산자를 사용하지 말라고 했었다. 하지만 편하게 사용할 수 있고, 한눈에 확 들어오는데 왜 사용하지 말하고 하는지 이유가 기억이 안 .. 2021. 10. 13.
해시 > 완주하지 못한 선수 문제 설명 수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다. 마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수들의 이름이 담긴 배열 completion이 주어질 때, 완주하지 못한 선수의 이름을 return 하도록 solution 함수를 작성해주세요. 제한사항 마라톤 경기에 참여한 선수의 수는 1명 이상 100,000명 이하입니다. completion의 길이는 participant의 길이보다 1 작습니다. 참가자의 이름은 1개 이상 20개 이하의 알파벳 소문자로 이루어져 있습니다. 참가자 중에는 동명이인이 있을 수 있습니다. 입출력 예 participant completion return ["leo", "kik.. 2021. 10. 12.
Duplicate Encoder Intructions The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate. Examples "din" => "(((" "recede" => "()()()" "Success" => ")())())" "(( @.. 2021. 10. 12.
정규회화과정 Level 7-8 : Unit 27. It Drives Me Crazy. STEP 4. 1:1 글쓰기 Today’s Topic Write about something that drives you crazy. What is it? Why does it bother you so much? Is there a way to fix the problem? Writing / 정필규 2021. 10. 11 A lazy perfectionist. One day, I watched video which said that word. That people seek perfection that they think. Also, they are lazy. They are not sure make end perfectly. So, They can not even start to the work, because of obsessio.. 2021. 10. 11.
정규회화과정 Level 7-8 : Unit 26. I’m So Embarrassed. STEP 4. 1:1 글쓰기 Today’s Topic When was the last time you were really embarrassed? What happened? How did you eliminate the embarrassment? Writing / 정필규 2021. 10. 11 As you know, because of pandemic the world is panic nowadays. The government publish that how many people affected corona virus every day for a wake up call for people. Fortunately, I got the first corona 19 pfizer vaccine about a month ago and I go.. 2021. 10. 11.
정규회화과정 Level 7-8 : Unit 25. You Have Such a Long Face. STEP 4. 1:1 글쓰기 Today’s Topic When was the last time you had a long face? What was wrong? How did you fix the problem? Writing / 정필규 2021. 10. 10 I will marry my girl friend soon. In fact, We bought first home as newly-wed couple before discuss about marriage. She and I gather the money together for buying the house. She got mortgage loan from her company and bank. Also, I got it from my father and bank. Actual.. 2021. 10. 11.
정규회화과정 Level 7-8 : Unit 24. I’m Satisfied with the Result. STEP 4. 1:1 글쓰기 Today’s Topic What are you most satisfied with in your life? What are you most dissatisfied with? Give details to support your answers. Writing / 정필규 2021. 10. 08 I like that feeling sense of accomplishment after settle a goal and make effort for fulfilling goal. When I feel sense of accomplishment, I am satisfied. I have several experience about satisfying. Let me talk about this. First, about .. 2021. 10. 11.
정규회화과정 Level 7-8 : Unit 23. What a Feeling! STEP 4. 1:1 글쓰기 Today’s Topic Have you ever hiked a mountain? If so, what is the tallest or most difficult mountain you have ever climbed? If not, explain the reasons why you have never climbed a mountain. Writing / 정필규 2021. 07. 21 (I have a question. Halla is name of the mountain and sna is meaning that a Mountain. Which word is better Halla Mountain and Hallasan Mountain at this time) When I was in childhood.. 2021. 7. 23.
정규회화과정 Level 7-8 : Unit 22. She Is an Active Person. STEP 4. 1:1 글쓰기 Today’s Topic Write about three things you could do to become a more active person. Give details to explain your answer well. Writing / 정필규 2021. 07. 21 The first one of things I could do to be more active is working out. While I have been working out at gym early in the morning everyday, I have been able to be a very active person. Before going to the company, I have exercised. As a result, som.. 2021. 7. 23.
정규회화과정 Level 7-8 : Unit 21. I Feel Like Changing My Appearance. STEP 4. 1:1 글쓰기 Today’s Topic Have you ever wanted to change your fashion style? If there was, how did you change it? Writing / 정필규 2021. 07. 16 The people(example, Jobs or Zuckerberg etc.) who tend to be expert of their field wear only one fashion. I heard they don't want to waste time for agonizing about the fashion. I was impressed with this. One day, I have wanted to change my fashion. I have gotten consult.. 2021. 7. 19.
정규회화과정 Level 7-8 : Unit 20. What Does He Look Like? STEP 4. 1:1 글쓰기 Today’s Topic What does your best friend look like? Give as many details as possible. Writing / 정필규 2021. 07. 14 There are many of friends. First friend: My girl friend is best friend number one of the world. We talk about many thing. Work, Future, Society etc. Let me talk about my best friend look like. She has long hair. The height is shorter than me, however she looks like similar to me. In m.. 2021. 7. 16.
정규회화과정 Level 7-8 : Unit 19. He Said that It Was a Great Party. STEP 4. 1:1 글쓰기 Today’s Topic Write about the best party you’ve ever attended. Why was it great? Is there anything you could do to make it better? Writing / 정필규 2021. 07. 14 Today's world, because of the virus, it is too hard that meeting people for party. The Korean government made policy, which was started yesterday, that every Korean should not meet more than 2 people from 6 p.m. to 5 a.m.(next day). Also th.. 2021. 7. 16.
정규회화과정 Level 7-8 : Unit 18. Thank You for the Invitation. STEP 4. 1:1 글쓰기 Today’s Topic What is the best way to invite someone to a special event like a wedding or a birthday party? Give details to support your answer. Writing / 정필규 2021. 06. 01 Here are three kinds of answer. First way to invite someone is using smartphone. These days, nobody doesn't have smartphone which has KakaoTalk(which is most famous chatting app in Korea). So, we can send invitation as smartph.. 2021. 6. 28.
정규회화과정 Level 7-8 : Unit 17. I’m Having a Housewarming Party. STEP 4. 1:1 글쓰기 Today’s Topic Some people like having housewarming parties. Others do not like them. How about you? Give details to support your opinion. Writing / 정필규 2021. 05. 31 I like having housewarming parties. Because the party is meaning that starting life at this house from now on and friends can congratulate about this. In my case, I like gathering my people. Two years ago, for example, I was being En.. 2021. 6. 28.