Baekjoon Algorithm | Problem 3052: Remainder
Source
https://www.acmicpc.net/problem/3052
Problem
Solve Baekjoon Online Judge problem 3052, Remainder.
Input
Follow the input format and constraints given in the original problem statement.
Output
Print the answer required by the problem.
Sample Input 1
1 2 3 4 5 6 7 8 9 10
Sample Output 1
10
Sample Input 2
42 84 252 420 840 126 42 84 420 126
Sample Output 2
1
Sample Input 3
39 40 41 42 43 44 82 83 84 85
Sample Output 3
6
Algorithm Classification
- Math
- Implementation
- Geometry
Solution
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
Set<Integer> nums = new HashSet();
for(int i = 0; i < 10; i++) {
int a = Integer.parseInt(br.readLine());
nums.add(a % 42);
}
System.out.println(nums.size());
}
}
}