SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
import java.util.Scanner;
import java.io.FileInputStream;
import java.util.HashSet;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++)
{
int N = sc.nextInt();
int plusN = N;
HashSet<String> answer = new HashSet<>();
while(true){
String N2 =Integer.toString(N);
String[] arr = N2.split("");
for(int i=0; i<arr.length; i++){
answer.add(arr[i]);
}
if(answer.size()==10)
break;
N=N+plusN;
}
System.out.println("#"+test_case+ " " + N);
}
}
}
처음엔 배열로 뭐 중복 제거하고 오름차순으로 집어넣으면서 풀어보려고 꾸역꾸역 했는데
그냥 중복 허용 안하는 Set 쓰면 편하다. 그리고 size로 해결
'SWEA' 카테고리의 다른 글
[SWEA] 최빈수 구하기 (0) | 2024.10.10 |
---|---|
[SWEA] 수도 요금 경쟁 (0) | 2024.10.10 |
[SWEA] 가랏! RC카! (0) | 2024.10.08 |
[SWEA] 간단한 압축 풀기 (0) | 2024.10.06 |
[SWEA] 간단한 소인수분해 (1) | 2024.10.06 |