알고리즘/SWEA
[D2] 1288 - 새로운 불면증 치료법
leegeonwoo
2023. 8. 14. 19:46
package SWEA;
import java.util.Scanner;
public class Solution1288 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int test_case = 1; test_case<=T; test_case++) {
int count = 0;
boolean[] checkVisit = new boolean[10]; //입력된 값들의 방문체크배열
int N = sc.nextInt();
int tmp = 0;
while(count < 10) {
tmp += N; // * N과 같은 식
String string_num = Integer.toString(tmp); //입력된 정수를 문자열로 변환
for(int i=0; i<string_num.length(); i++) {
int num = Character.getNumericValue(string_num.charAt(i)); //변환한 문자열을 한자리의 숫자로 바꿈
if(checkVisit[num]==false) { //해당하는 인덱스의 false를 true로 바꿈
checkVisit[num] = true;
count+= 1;
}
}
}
System.out.println("#" + test_case + " " + tmp);
}
}
}
728x90