-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_3052.java
More file actions
75 lines (63 loc) · 1.61 KB
/
_3052.java
File metadata and controls
75 lines (63 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package backjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
// https://www.acmicpc.net/problem/3052
// 나머지
public class _3052 {
public static void main(String[] args) throws IOException {
// sol1. BufferedReader와 리스트로 풀기
// memory 11460 runtime 76
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// 나머지값이 들어 갈 리스트 생성
List<Integer> list = new ArrayList<>();
// 리스트에 나머지값 넣기
for(int i = 0; i< 10; i++) {
int reminder = Integer.parseInt(br.readLine()) % 42;
if (!list.contains(reminder)) {
list.add(reminder);
}
}
System.out.println(list.size());
// sol2 Scanner와 배열로만 풀기기
// memory 18340 runtime 240
/*
Scanner sc = new Scanner(System.in);
int[] num = new int[10]; //입력값이 들어갈 배열
int[] number = new int[1000]; // 전체배열
int a = 42;
int count = 0;
for (int i = 0; i < 10; i++) {
int n = sc.nextInt();
num[i] = n % a;
}
for (int i = 0; i < num.length; i++) {
number[num[i]]++; // num값을 number의 num값 배열에 넣어줘서 1씩 증가시킴
//System.out.printf("i: %d, num[%d]: %d, number[%d]: %d%n", i, i, num[i], i, number[i]);
} // 값이 있으면 1, 없으면 0이 됨
for (int i = 0; i < number.length; i++) {
if (number[i] != 0) {
count++;
}
}
System.out.println(count);
*/
}
}
/*
input
1
2
3
4
5
6
7
8
9
10
output
10
*/