민석아... 그냥 자라... 만나면 진짜... 평생 잠에서 못깨게한다...
package oSWExpertAcademy;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
public class D2_1288 {
public static void main(String[]args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
int testCase = Integer.parseInt(br.readLine());
for(int tc=1; tc<=testCase; tc++) {
//시작하는 번호를 입력해준다.
int number = Integer.parseInt(br.readLine());
//0부터 9까지의 숫자를 문자로 입력해준다. 중복은 허용하지 않아야 해서 Set중의 TreeSet을 사용해준다.
TreeSet<String> set = new TreeSet<String>();
//for문을 돌려서 얼마나 돌았는지 카운팅 해주기 위해 count를 생성해서 초기값 1을 넣어준다.
int count = 1;
//출력되는 값 초기화시켜준다.
int result = 0;
//사이즈는 0부터 9까지 이야 하므로.. 10보다 작아야한다. you know? righttttttt?
while(set.size()<10) {
result = count * number;
//String 형태로 변환하여 배열에 넣어준다 ㅎㅎㅎ
String[] str = Integer.toString(result).split("");
//향상된 for문으로 TreeSet에 입력해준다. 이때, 중복되는 숫자는 저장되지 않음으로 쉽게 0부터 9까지의 숫자를 모을수있다.
for(String input:str) {
set.add(input);
}
count++;
}
System.out.println("#"+tc+" "+result);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
'Java > SW Expert Academy' 카테고리의 다른 글
1204. 최빈수 구하기 (0) | 2021.01.12 |
---|---|
1284. 수도 요금 경쟁 (0) | 2021.01.12 |
1928. Base64 Decoder (0) | 2021.01.12 |
1940. 가랏! RC카! (0) | 2021.01.11 |
1945. 간단한 소인수분해 (0) | 2021.01.11 |
댓글