• 문제 링크
https://www.acmicpc.net/problem/18406
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String s = br.readLine();
bw.write(sum(Integer.parseInt(s.substring(0, s.length() / 2))) == sum(Integer.parseInt(s.substring(s.length() / 2))) ? "LUCKY" : "READY");
bw.flush();
}
private static int sum(int n) {
int sum = 0;
do sum += n % 10; while ((n /= 10) > 0);
return sum;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 1284 집 주소 - Implementation / Java (0) | 2025.01.14 |
---|---|
[백준] 1652 누울 자리를 찾아라 - Implementation / Java (0) | 2025.01.13 |
[백준] 9076 점수 집계 - Implementation / Java (0) | 2025.01.11 |
[백준] 6124 Good Grass - Brute Force / Java (0) | 2025.01.10 |
[백준] 17093 Total Circle - Brute Force / Java (0) | 2025.01.09 |
댓글