• 문제 링크
https://www.acmicpc.net/problem/6751
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int y = read();
do y++; while (isDistinct(y));
bw.write(String.valueOf(y));
bw.flush();
}
private static boolean isDistinct(int y) {
boolean[] arr = new boolean[10];
do {
if (arr[y % 10]) return true;
arr[y % 10] = true;
} while ((y /= 10) > 0);
return false;
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 15234 Number Pairs - Brute Force / Java (0) | 2024.09.05 |
---|---|
[백준] 9229 단어 사다리 - Brute Force / Java (0) | 2024.09.04 |
[백준] 11116 교통량 - Brute Force / Java (0) | 2024.09.02 |
[백준] 3154 알람시계 - Brute Force / Java (0) | 2024.09.01 |
[백준] 1357 뒤집힌 덧셈 - Implementation / Java (0) | 2024.08.31 |
댓글