전체 글
-
백준 1929번 소수 구하기알고리즘 2022. 5. 14. 16:57
출처 링크: https://www.acmicpc.net/problem/1929 처음 나의 풀이 // 에라토스 테네스의 체 이용하기? 근데 이건 소수가 있는 지 없는 지 판별할 때 썼던 것 같은데?? // 각각의 수가 1과 자기 자신을 제외한 약수가 있는지 없는지 판별해야 함 // 1과 자기 자신 사이의 수 중에서 자기자신 나누기 특정 수를 했을 때 나머지가 0인 경우가 있다면 제외처리 // m은 1이상 n은 2이상이 되어야 소수가 적어도 1개 이상 나올 수 있음 // 입력값 const m = 3 const n = 16 let answer = [] let count = 0 if (m === 1) { answer.push(2) for (let i = 2; i
-
백준 10250번 ACM 호텔알고리즘 2022. 5. 9. 21:57
출처 링크: https://www.acmicpc.net/problem/10250 ACM 호텔 매니저 지우는 손님이 도착하는 대로 빈 방을 배정하고 있다. 고객 설문조사에 따르면 손님들은 호텔 정문으로부터 걸어서 가장 짧은 거리에 있는 방을 선호한다고 한다. 여러분은 지우를 도와 줄 프로그램을 작성하고자 한다. 즉 설문조사 결과 대로 호텔 정문으로부터 걷는 거리가 가장 짧도록 방을 배정하는 프로그램을 작성하고자 한다. 문제를 단순화하기 위해서 호텔은 직사각형 모양이라고 가정하자. 각 층에 W 개의 방이 있는 H 층 건물이라고 가정하자 (1 ≤ H, W ≤ 99). 그리고 엘리베이터는 가장 왼쪽에 있다고 가정하자(그림 1 참고). 이런 형태의 호텔을 H × W 형태 호텔이라고 부른다. 호텔 정문은 일층 엘리..
-
백준 2869번 달팽이는 올라가고 싶다.알고리즘 2022. 5. 9. 16:22
출처 링크: https://www.acmicpc.net/problem/2869 땅 위에 달팽이가 있다. 이 달팽이는 높이가 V미터인 나무 막대를 올라갈 것이다. 달팽이는 낮에 A미터 올라갈 수 있다. 하지만, 밤에 잠을 자는 동안 B미터 미끄러진다. 또, 정상에 올라간 후에는 미끄러지지 않는다. 달팽이가 나무 막대를 모두 올라가려면, 며칠이 걸리는지 구하는 프로그램을 작성하시오. 첫째 줄에 세 정수 A, B, V가 공백으로 구분되어서 주어진다. (1 ≤ B < A ≤ V ≤ 1,000,000,000) 첫째 줄에 달팽이가 나무 막대를 모두 올라가는데 며칠이 걸리는지 출력한다. 다시 풀었을 때 풀이 const path = process.platform === 'linux' ? '/dev/stdin' : 'i..
-
백준 4948번 베르트랑 공준알고리즘 2022. 5. 9. 15:08
출처 링크: https://www.acmicpc.net/problem/4948 베르트랑 공준은 임의의 자연수 n에 대하여, n보다 크고, 2n보다 작거나 같은 소수는 적어도 하나 존재한다는 내용을 담고 있다. 예를 들어, 10보다 크고, 20보다 작거나 같은 소수는 4개가 있다. (11, 13, 17, 19) 또, 14보다 크고, 28보다 작거나 같은 소수는 3개가 있다. (17,19, 23) 자연수 n이 주어졌을 때, n보다 크고, 2n보다 작거나 같은 소수의 개수를 구하는 프로그램을 작성하시오. 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 케이스는 n을 포함하는 한 줄로 이루어져 있다. 입력의 마지막에는 0이 주어진다. (범위: 1 ≤ n ≤ 123,456) 풀이 let input = [1,..
-
항해 99 5기 후기항해 99 2022. 4. 18. 17:51
항해 99 5기가 4.15부로 끝이 났다. 아마 주위 분들, 혹은 어딘가의 검색을 타고 들어오신 분들이 궁금해하실 수도 있을 것 같다. 짧게나마 후기를 한번 써보려 한다. "결론부터 말하자면 1) 빠르게 개발자로써 취업하고 싶거나 2) 개발 실무를 겪어보고 싶은 휴학한 컴공 전공생, 3) 자기 주도적으로 문제를 해결하고 싶은 사람 4) 3개월 이상 혼자 개발 공부해본 사람, 4가지 중 하나 이상 해당된다면 추천한다." (+ 항해 수료 기수 중 지인이 있다면 결제 전에 추천을 받아보자! 추천해주시는 분은 20만원, 추천 받는 분은 결제 시 30만원 할인 혜택이 있다. "없다면 제 방명록에 원한다고 남겨주셔요!" 이 따옴표 문장이 없어지지 않았다면 제가 추천 가능하단 말이니 바로 말씀해주세요! 물론 열심히 ..
-
항해 99 5기 TIL_93항해 99 2022. 4. 14. 00:36
▶ Today I Learned [package.json이 꼭 필요할까요?] 꼭 필요하다. 왜냐하면 npm이 이를 통해 프로젝트를 식별하고 어떤 패키지를 의존하고 있는지 의존(dependency & devdependency)파일을 참고하고 종속처리를 해주기 때문이다. package.json은 npm이라는 오픈소스 패키지 생태계를 사용하기 위한 명세이자, 프로젝트의 의존성 관리를 위한 명세, 또 이 생태계로의 배포를 위한 명세라고 볼 수 있다. 특정 패키지를 npm install을 통해 설치할 때 npm registry로 부터 그 패키지를 가져오는 것이며 이때 패키지에 대한 정보가 package.json에 들어있어야만 한다. 그렇지 않으면 npm에 있는 패키지를 설치하거나 npm에 패키지를 배포할 수 없다..
-
항해 99 5기 TIL_92항해 99 2022. 4. 13. 10:21
▶ Today I Learned 우리 프로젝트에 적용된 도커를 하나씩 뜯어보며 공부해보자. .dockerignore: docker 이미지를 빌드할 때 제외할 파일을 정해준다. 현재 우리는 아래와 같이 노드의 모듈들과 .gitignore 파일은 올라가지 않도록 하고 있다. # Dependency directories node_modules/ .gitignore Dockerfile.dev: 도커 공식문서에 보면 아래와 같은 문구가 있다. In order to build the application, we need to use a Dockerfile. A Dockerfile is simply a text-based script of instructions that is used to create a conta..