슈콩

[SWEA] 두 전구 본문

Algorithms/SWEA

[SWEA] 두 전구

shukong 2025. 11. 15. 23:58

 

 

[문제]

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AXuUo_Tqs9kDFARa

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

 

[소스 코드]

import java.io.*;
import java.util.*;
public class Solution {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int T = Integer.parseInt(br.readLine());
		for(int tc=1;tc<=T;tc++) {
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			int d = Integer.parseInt(st.nextToken());
			int start = Math.max(a, c);
			int end = Math.min(b, d);
			int result = Math.max(0, end-start);
			System.out.println("#"+tc+" "+result);
		}
	}
}

'Algorithms > SWEA' 카테고리의 다른 글

[SWEA] 팔씨름  (0) 2025.11.16
[SWEA] 유효숫자 표기  (0) 2025.11.16
[SWEA] 제곱수 만들기  (0) 2025.11.15
[SWEA] 구구단 걷기  (0) 2025.11.15
[SWEA] 공과 잡초  (0) 2025.11.15