-
항해 99 5기 TIL_50항해 99 2022. 3. 1. 01:25
▶ Today I Learned
<알고리즘>
[달팽이는 올라가고 싶다]
소요시간: 30분
해결 여부: 해결
백준 2869번 문제
https://www.acmicpc.net/problem/2869
Replit에서 풀어본 나의 풀이
/* A만큼 더하고 B만큼 빼다가 V에 도달했을때 까지의 반복 수 시간 복잡도가 낮아야함 시간제한 0.25초! -> 반복문을 쓰지 말자! */ // 입력 값 예시 let a = 2 let b = 1 let v = 5 let n = a - b // x가 구하고자하는 일수일 경우, v = a + (x-1)*n -> 마지막에 a번 올라가는 것도 // 하루로 쳐야하기 때문에 a값은 따로 더해주고 x에 1을 뺀다! // (v - a)/n = x - 1 let answer = Math.ceil((v - a)/n + 1) //x에 소숫점이 있을 경우 올림 처리 console.log(answer)
백준 풀이
const path = process.platform === 'linux' ? '/dev/stdin' : 'input.txt' const input = require("fs").readFileSync(path).toString().trim().split('\n') let a = input[0].split(' ')[0]/1 let b = input[0].split(' ')[1]/1 let v = input[0].split(' ')[2]/1 let n = a - b let answer = Math.ceil((v - a)/n + 1) console.log(answer)
<실전 프로젝트>
실전프로젝트에서 실시간 채팅 기능을 구현하려면 web socket에 대해서 알 필요가 있다.
- wss (Web Socket Server)는 uri에 입력가능하다.
- 브라우저에는 내장된 web socket API가 있음
강의를 따라하며 알게된 것은 이 정도이지만 내일은 더 많이 듣고 정리해 보아야겠다.
▶ 느낀 점
개인적인 일로 신경쓸 게 많은 요즘이라 진이 좀 빠지긴 하지만
너무 신경쓰지 말자. 지금은 그저 하고 싶었던 이 일에 더욱 집중할 수 있었으면 좋겠다.
내일도 화이팅팅 :)
▶ 공부 시 참고 링크들
https://www.npmjs.com/package/express-handlebars
'항해 99' 카테고리의 다른 글
항해 99 5기 TIL_52 (0) 2022.03.03 항해 99 5기 TIL_51 (0) 2022.03.02 항해 99 5기 WIL_7 (0) 2022.02.27 항해 99 5기 TIL_49 (0) 2022.02.27 항해 99 5기 TIL_48 (0) 2022.02.27