전체 글
-
4013. [모의 SW 역량테스트] 특이한 자석 - 자바(JAVA)알고리즘/SW Expert Academy 2022. 5. 30. 00:01
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWIeV9sKkcoDFAVH SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 문제 해석 특이한 자석 4개가 존재하며 8개의 날을 가지고 있습니다. 자석의 각 날마다 N극 또는 S극을 가지고 있으며 자석을 일렬로 배치되어 있습니다. 자석에는 규칙이 존재합니다. 서로 붙어있는 날의 자성이 다를 경우 인력에 의해 반대 방향으로 1칸 회전됩니다. 특이한점은 회전하면서 검사하는것이 아니라 어떤 자석이 회전하기 전에 인접하여있는 극들이 같은지 아닌지 검사하고 극이 같다면 회전하지 않고..
-
불변객체란 무엇인가?Java 2022. 5. 29. 19:07
불변 객체란? 객체 생성 이후 내부의 상태가 변하지 않는 객체입니다. 불변 객체는 read-only 메서드만을 제공하며 객체의 내부 상태를 제공하는 메서드를 제공하지 않거나 방어적 복사를 통해 제공합니다. Java 대표적인 불변 객체로는 String이 있습니다. 방어적 복사란? 예를 들어 Java의 String은 불변 객체 이기 때문에 String의 내부의 char형 배열을 얻어 수정을 해도 반영이 되지 않습니다. String은 객체이기 때문에 참조를 통해 값을 수정하면 내부의 상태가 변하기 때문에 내부를 복사하여 전달하는 것을 방어적 복사라고 합니다. 실제로 다음과 같이 name은 변경해도 변하지 않습니다. String name = "Old"; char changed = name.toCharArray(..
-
[백준] 1937번 : 욕심쟁이 판다 - 자바(JAVA)알고리즘/백준 2022. 5. 29. 00:01
https://www.acmicpc.net/problem/1937 1937번: 욕심쟁이 판다 n × n의 크기의 대나무 숲이 있다. 욕심쟁이 판다는 어떤 지역에서 대나무를 먹기 시작한다. 그리고 그 곳의 대나무를 다 먹어 치우면 상, 하, 좌, 우 중 한 곳으로 이동을 한다. 그리고 또 그곳에 www.acmicpc.net 문제 해석 n x n의 크기 대나무 숲이 존재합니다. 욕심쟁이 판다는 어떤 지역에서 대나무를 먹기 시작합니다. 그리고 그곳의 대나무를 다 먹어 치우면 상, 하, 좌, 우 중 한 곳으로 이동합니다. 그리고 그곳에서 또 대나무를 먹습니다. 대나무를 먹는 조건 1. 옮긴 지역에는 전 지역보다 대나무가 많아야 한다. 판다가 최대한 많은 칸을 이동하려면 어떤 경로를 통하여 움직여야 하는지 구하라..
-
Java에 원시타입(primitive type)이 존재하는 이유Java 2022. 5. 28. 13:17
한 줄 요약하자면 다음과 같습니다. 원시 타입이 참조 타입에 비해 메모리 및 CPU 처리 측면에서 더 가볍고 효율적이기 때문입니다. 원시 타입과 참조 타입 자바에서는 데이터 타입을 크게 두 가지 원시 타입과 참조 타입이 있습니다. 원시 타입은 정수, 실수, 문자, 논리 등의 실제 데이터 값을 저장하는 타입입니다. 참조 타입은 객체의 주소를 저장하는 타입으로 메모리 번지 값을 통해 객체를 참조하는 타입입니다. 최근에 Java는 왜 Pure OOP가 아닐까?라는 질문에 대답을 하는 과정에서 원시 타입을 지원하고 있기 때문에라고 대답했습니다. https://junuuu.tistory.com/286?category=968252 Java는 왜 Pure OOP가 아닐까? Pure OOP란? 말 그대로 순수하게 완전..
-
Reliable UDP(RUDP)란 무엇인가?CS/네트워크 2022. 5. 28. 12:15
간략한 TCP/ UDP 소개 TCP는 통신을 할 때 클라이언트에서 connect를 열어 서버와 소통하게 됩니다. 하지만 UDP의 경우에는 connect를 열지 않고 일방적으로 server에서 client에 데이터를 보내주고 데이터를 정확하게 받았는지 확인하지 않습니다. 이러한 차이점 때문에 데이터의 신뢰성은 UDP TCP입니다. 따라서 TCP를 신뢰성있는 프로토콜이라고 부르고, UDP는 비신뢰성 프로토콜이라 알 고 있었습니다. 다음은 TCP와 UDP의 헤더 구조인데 TCP에 비해 UDP는 매우 간단한 구조를 갖습니다. TCP 헤더 구조 UDP 헤더 구조 Reliable UDP(RUDP)란? UDP 또한 RUDP라는 방법으로 신뢰성을 보장하기도 합니다. TCP에서 신뢰성..
-
8458. 원점으로 집합 - 자바(JAVA)알고리즘/SW Expert Academy 2022. 5. 28. 00:01
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWzaq5KKk_ADFAVU SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 문제 해석 N개의 정점이 존재하며 이 정점들을 원점으로 이동시키려고 합니다. 정점들은 상하좌우로 움직일 수 있으며, i번째 움직임에서는 i번 움직이는 특성을 가지고 있습니다. 이때 최소 몇 번의 이동만에 원점으로 이동할 수 있는지 구하세요 문제 풀이 전 설계 1. 가장 먼 점이 원점으로 이동할 때까지, 먼저 원점에 도달한 점들은 +1, -1 운동을 반복하게 됩니다. (즉, 모든 점들은 모두 홀수이거..
-
[백준] 3176번 : 도로 네트워크 - 자바(JAVA)알고리즘/백준 2022. 5. 27. 00:01
https://www.acmicpc.net/problem/3176 3176번: 도로 네트워크 첫째 줄에 N이 주어진다. (2 ≤ N ≤ 100,000) 다음 N-1개 줄에는 도로를 나타내는 세 정수 A, B, C가 주어진다. A와 B사이에 길이가 C인 도로가 있다는 뜻이다. 도로의 길이는 1,000,000보다 작거나 같은 양 www.acmicpc.net 문제 해석 N개의 도시와 그 도시를 연결하는 N-1개의 도로로 이루어진 도로 네트워크가 존재합니다. 모든 도시의 쌍에는 그 도시를 연결하는 유일한 경로가 있고, 각 도로의 길이는 입력으로 주어집니다. 총 K개의 도시 쌍이 주어질 때, 경로 상에서 가장 짧은 도로의 길이와 가장 긴 도로의 길이를 구하는 프로그램을 작성하세요 문제 풀이 전 설계 N개의 도시와..
-
[백준] 17472번 : 다리 만들기 2 - 자바(JAVA)알고리즘/백준 2022. 5. 26. 00:01
https://www.acmicpc.net/problem/17472 17472번: 다리 만들기 2 첫째 줄에 지도의 세로 크기 N과 가로 크기 M이 주어진다. 둘째 줄부터 N개의 줄에 지도의 정보가 주어진다. 각 줄은 M개의 수로 이루어져 있으며, 수는 0 또는 1이다. 0은 바다, 1은 땅을 의미한다. www.acmicpc.net 문제 해석 섬으로 이루어진 나라가 존재하고 모든 섬을 다리로 연결하려고 합니다. 이 나라의 지도는 N x M 크기의 이차원 격자로 나타잴 수 있으며 격자의 각 칸은 땅이거나 바다입니다. 파란색은 땅을 의미합니다. 다리를 놓아 섬A와 섬B를 연결하고자 할때 제약사항은 다음과 같습니다. 다리는 바다에만 건설할 수 있습니다. 다리의 길이는 2 이상이여야 합니다. 다리는 방향이 중간..