

꽤 고전했던 기억이 있습니다. 나머지야 앞선 문제들로 해결이 가능하지만, 중복되는 숫자를 어떻게 제거할 것인가? 이 부분이 걸립니다. 저는 중복되는 숫자가 나올때마다 셈을 빼는 것으로 해결했습니다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int arr[] = new int[10];
int eo = 10;
for (int i=0; i<10; i++) {
arr[i] = Integer.parseInt(br.readLine());
arr[i] = arr[i]%42;
}
for (int j=0; j<9; j++) {
for (int k=j+1; k<10; k++) {
if (arr[j] == arr[k] ) {
eo = eo - 1;
}
}
}
System.out.println(eo);
}
}'백준 문제풀이 > 1차원 배열' 카테고리의 다른 글
| 4344. 평균은 넘겠지. (0) | 2022.09.12 |
|---|---|
| 8958. OX퀴즈 (0) | 2022.09.12 |
| 1546. 평균 (0) | 2022.09.12 |
| 2562. 최댓값 (0) | 2022.09.12 |
| 10818. 최소, 최대 (0) | 2022.09.12 |