전체 글
-
[백준] 2609번 최대공약수와 최소공배수알고리즘 2023. 3. 13. 23:01
유클리드 호제법1. 먼저 두개의 수를 서로 나눈 나머지를 구한다. ex) 1071 % 1029 = 422. 두 수 중 작은 수를 다시 나머지로 나눈다. ex) 1029 % 42 = 213. 나누어 떨어질때까지 반복한다.4. 나누어떨어지면 나눈 수가 최대공약수가 된다. ex) 42 % 21 = 0 최대공약수는 21 최소공배수 = A X B / 최대공약수 const input = require('fs') .readFileSync('/dev/stdin') .toString() .trim() .split(' '); let a = input[0]; let b = input[1]; while (a % b !== 0) { let n = a % b; if (n !== 0) { a = b; b = n; } } conso..
-
[백준] 1152번 단어의 개수알고리즘 2023. 2. 10. 00:19
https://www.acmicpc.net/problem/1152 처음 생각했던 답sentence = list(input().split()) print(len(sentence))→ 이 풀이도 틀린 답은 아니지만 더 간단하게 풀 수 있는 방법이 있었다. split함수는 문자열을 공백기준으로 나누어 리스트로 반환해주기 때문에 list로 굳이 바꾸지 않아도 된다. 반환되는 타입을 생각해보지 않았는데, 이번에 알게되어서 절대 잊지 않을 것 같다.더 간단한 답sentence = input().split() print(len(sentence)) Uploaded by Notion2Tistory v1.1.0
-
[백준] 1110 더하기 사이클알고리즘 2023. 2. 10. 00:19
https://www.acmicpc.net/problem/1110 처음에는 단순하게 문자열로 처리해서 숫자끼리 더하고 원래 숫자와 비교하려고 했는데, 시간초과가 발생했다. 시간초과 발생한 풀이n = input() num = n count = 0 while True: if len(num) == 1: num = '0' + num count += 1 new_n = str(int(num[0]) + int(num[1])) num = num[-1] + new_n[-1] if num == n: print(count) break 처음부터 int형으로 받고 10으로 나눠서 나머지끼리 더하면 괜찮을 것 같아서 시도해보았다.n = int(input()) num = n count = 0 while True: count += ..
-
[CS] Blocking, Non-Blocking, Sync, AsyncCS 2023. 1. 11. 22:58
💡https://www.youtube.com/watch?v=oEIoqGd-Sns위 영상을 보고 작성한 글입니다. 1. Blocking vs Non-Blocking제어의 관점 : 다른 주체가 작업할 때 자신의 제어권이 있는지 없는지로 볼 수 있다.Blocking : 자신의 작업을 진행하다가 다른 주체의 작업이 시작되면 다른 작업이 끝날 때까지 기다렸다가 자신의 작업을 시작하는 것Non-Blocking : 다른 주체의 작업에 관련없이 자신의 작업을 하는 것 2. Sychronous VS Asynchronous순서와 결과(처리)의 관점 : 결과를 돌려주었을 때 순서와 결과에 관심이 있는지 아닌지로 판단할 수 있다.Sychronous : 동기, 작업을 동시에 수행하거나, 동시에 끝나거나 끝나는 동시에 시작함을 ..
-
[CS] 가상메모리CS 2023. 1. 6. 01:56
💡https://www.youtube.com/watch?v=5pEDL6c--_k위 영상을 보고 정리한 글입니다.가상메모리 가상메모리 배경지식컴퓨터 구조레지스터자료를 보관하는 매우 빠른 기억 장소메인 메모리빠르지만 용량이 작고 휘발성DISK느리지만 용량이 크고 비휘발성더 많은 내용을 저장하기 위해 사용 프로그램이 실행되는 것주소 바인딩컴파일 타임 바인딩로드 타임 바인딩실행 시간 바인딩 스왑영역 가상메모리메모리 관리 기법 중 하나로 프로세스 전체가 메모리 내에 올라오지 않더라도 실행이 가능하다록 하는 기법사용자 프로그램이 물리 메모리의 제약에서 벗어남사용자 프로그램이 물리 메모리보다 커져도 됨프로그래머는 물리 메모리 크기를 신경쓰지 않아도 되기 때문에 실제 해결하고자 하는 문제에 집중 가능각 프로그램이 더 ..
-
[CS] MVCCS 2022. 12. 28. 23:17
https://www.youtube.com/watch?v=ogaXW6KPc8I 위 영상을 시청하고 정리한 내용입니다. MVC MVC 탄생 이유 유지보수가 편해지는 코드 구성 방식을 취하기 위해서 MVC Model : 데이터와 관련된 부분 View : 사용자한테 보여지는 부분 Controller : Model과 View를 이어주는 부분 MVC를 지키면서 코딩하는 방법 Model은 Controller와 View에 의존하지 않아야 한다. 즉, Model 내부에 Controller와 View에 관련된 코드가 있으면 안된다. View는 Model에만 의존해야하고, Controller의 코드가 있으면 안된다. 즉, View 내부에 Model의 코드만 있을 수 있고, Controller의 코드가 있으면 안된다. Vi..
-
[백준] 1890번 점프알고리즘 2022. 12. 20. 02:25
https://www.acmicpc.net/problem/1890 # 1890 : 점프 import sys n = int(sys.stdin.readline()) game = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] # dp 테이블 dp = [[0] * n for _ in range(n)] dp[0][0] = 1 # 반복문을 통해 갈 수 있는 그래프의 좌표를 탐색 for i in range(n): for j in range(n): # 오른쪽 끝 점이면 중지 if i == n - 1 and j == n - 1: print(dp[i][j]) break # 오른쪽으로 이동 if j + game[i][j] < n: dp[i][j + gam..
-
[백준] 10164번 격자상의 경로알고리즘 2022. 12. 20. 02:25
https://www.acmicpc.net/problem/10164 count는 k를 찾기 위해 설정k가 0이 아니면 k까지 가는 경우의 수와 k부터 끝점까지 가는 경우의 수를 곱해주면 된다. # 10164 : 격자상의 경로 import sys input = sys.stdin.readline n, m, k = map(int, input().rstrip().split()) dp = [[0] * (m + 1) for _ in range(n + 1)] dp[0][1], count = 1, 1 for i in range(1, n + 1): for j in range(1, m + 1): # k일 시 현재 위치 저장 if count == k: sx = i sy = j # k 찾기 위해 1씩 증가 count += 1..