본문 바로가기

전체 글137

[백준] 1022번 소용돌이 예쁘게 출력하기 #include #define _CRT_SECURE_NO_WARNINGS#include #define MAX 10001using namespace std;int arr[51][5] = { 0, };// 오, 위, 왼, 아int dx[] = { 0, -1, 0, 1 };int dy[] = { 1, 0, -1, 0 };int main() { int r1, c1, r2, c2; scanf("%d %d %d %d", &r1, &c1, &r2, &c2); int len = 1; int cnt = 1; int x = 0, y = 0; if (r1 cnt: 몇 칸 왔는지, len: 몇 칸 가야 되는지(1 1 2 2 ...)로 2번에 1칸씩 이동하게 되므로 증가curLen: 현재까지 이동한 칸 수 printf("%*.. 2025. 3. 22.
[백준] 13317번 한 번 남았다 #define fastio cin.tie(0)->sync_with_stdio(0)using namespace std;int main(){ fastio; cout0; i--) couthttps://measurezero.tistory.com/419 N: 정점 개수 (50 ≤ N ≤ 100), M: 간선 개수 (0 ≤ M ≤ N * (N-1)), M개의 간선 정보 (u, v, w)findNegativeCycle_Wrong()가 잘못된 구현이라, 이를 이용한 논리를 깨뜨리는 반례를 찾아야 함findNegativeCycle()은 벨만-포드 알고리즘을 올바르게 구현하여 N-1번 반복함 findNegativeCycle_Wrong()은 반복 횟수가 N-2라서 일부 케이스에서 오류 발생 가능.정점 50개, 간.. 2025. 3. 21.
[3] 자바 중급 문법 3 -- 날짜와 시간 플젝하다보면 날짜를 다루는 경우가 꼭 있는데 그때마다 찾기 귀찮아서 정리해뒀다..[1] 날짜와 시간 라이브러리[2] 문제 1 --2024년 1월 1일 0시 0분 0초에서 1년 2개월 3일 4시간 후의 시각을 찾아라.public class Test { public static void main(String[] args) { LocalDateTime time = LocalDateTime.of(2024,01,01,0,0,0,0); LocalDateTime gap = time.plusYears(1).plusMonths(2).plusDays(3).plusHours(4); System.out.println("기준 시각: "+ time); System.out.p.. 2025. 3. 21.
[2] 자바 중급 문법 2 [1] 참조값public class Address { private String value; @Override public String toString() { return "Address{" + "value='" + value + '\'' + '}'; } public Address(String value) { this.value = value; } public String getValue() { return value; } public void setValue(String value) { this.value = value; }}public class.. 2025. 3. 21.