전체 글
-
[BOJ] 2108번: 통계학Algorithm/Baekjoon Online Judge 2022. 3. 26. 01:45
https://www.acmicpc.net/problem/2108 2108번: 통계학 첫째 줄에 수의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 단, N은 홀수이다. 그 다음 N개의 줄에는 정수들이 주어진다. 입력되는 정수의 절댓값은 4,000을 넘지 않는다. www.acmicpc.net Python3 import sys from collections import Counter N = int(input()) numbers = [] for _ in range(N): numbers.append(int(sys.stdin.readline())) numbers.sort() print(round(sum(numbers)/N)) print(numbers[N//2]) nums = Counter(numbers)...
-
[BOJ] 10989번: 수 정렬하기 3Algorithm/Baekjoon Online Judge 2022. 3. 26. 00:53
https://www.acmicpc.net/problem/10989 10989번: 수 정렬하기 3 첫째 줄에 수의 개수 N(1 ≤ N ≤ 10,000,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수가 주어진다. 이 수는 10,000보다 작거나 같은 자연수이다. www.acmicpc.net Python3 수 정렬하기 2의 문제와 비슷해보였여 제출했던 코드를 그대로 제출해보았다. https://miraekwak.tistory.com/72 [BOJ] 2751번: 수 정렬하기 2 https://www.acmicpc.net/problem/2751 2751번: 수 정렬하기 2 첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수가 주어진다. 이 수는 절댓값이 1,..
-
[Algorithm] 정렬 알고리즘 & Python3 코드 & 시간복잡도 정리Algorithm/Algorithm Theory 2022. 3. 26. 00:23
1. 병합 정렬 분할 정복 방식을 이용한 알고리즘으로 말 그대로 배열을 분할 후 정렬하면서 병합하는 방식이다. 배열의 원소를 절반씩 잘라 계속해서 나눈 후 => 분할 배열의 원소의 개수가 1개가 되면 이웃한 배열의 원소와 크기를 비교하여 정렬하면서 합치기 => 병합 다음과 같이 그림으로 나타낼 수 있다. 분할을 하게되면 분할되는 깊이가 N log N에 비례하고 배열을 합치는 과정을 생각하면 최대 배열의 개수는 N개, 즉 원소의 개수만큼 생기게 되어 N에 비례한다. 따라서 병합정렬의 시간 복잡도는 O(N log N) 이다 Python3 Code def merge_sort(numbers): if len(numbers) = right[r]: numbers[i] = right[r] r += 1 else: num..
-
[BOJ] 2751번: 수 정렬하기 2Algorithm/Baekjoon Online Judge 2022. 3. 26. 00:05
https://www.acmicpc.net/problem/2751 2751번: 수 정렬하기 2 첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수가 주어진다. 이 수는 절댓값이 1,000,000보다 작거나 같은 정수이다. 수는 중복되지 않는다. www.acmicpc.net Python3 초기 코드 if __name__ == '__main__': N = int(input()) numbers = [] for _ in range(N): numbers.append(int(input())) numbers.sort() print(*numbers, sep="\n") 이전에 풀었던 정렬 문제와 유사하다고 생각했고 파이썬 내장함수인 sort()를 사용해 해결하려고 했다...
-
[Network] IP Address, Class&Subnet mask, CIDR, Reserved IP Address 정리Computer Science/Network 2022. 3. 24. 01:28
내가 보기위해 만든 요약정리 본 IP 주소 IP란 Internet Protocol의 약자로 인터넷 상에서 데이터를 주고 받기 위한 통신 규약이다. 이 통신을 하기 위해서 컴퓨터 네트워크 장치들이 사용하는 특수한 번호를 ip 주소라고 한다. 현재 인터넷에서 사용하는 표준 프로토콜은 IPv4이다. 하지만 이는 주소 공간 고갈 문제가 있어 나중엔 IPv6가 이를 대체할 것이라고 한다. IPv4 168.188.123.123과 같이 점을 기준으로 4마디로 구분되는 형식을 가진다. 점으로 구분되는 4개의 영역은 옥텟이라고 불린다. 각 옥텟은 0-255까지의 범위를 가져 IPv4는 0.0.0.0 부터 255.255.255.255까지의 주소를 사용한다. 옥텟은 8bit로 표현되어 32bit 주소가 된다. 이는 2^32..