Published 2020. 12. 29. 03:58
 

3052번: 나머지

각 수를 42로 나눈 나머지는 39, 40, 41, 0, 1, 2, 40, 41, 0, 1이다. 서로 다른 값은 6개가 있다.

www.acmicpc.net

#include <iostream>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

	int his[42] = {};

	int input[10] = {};
	for (size_t i = 0; i < 10; i++) {
		cin >> input[i];
		his[input[i] % 42]++;
	}
	int cnt = 0;
	for (int& n : his) { 
		if (n != 0) { cnt++; }
	}
	cout << cnt;
	return 0;
}

'Problem set' 카테고리의 다른 글

[백준] 6588: 골드바흐의 추측  (0) 2020.12.29
[백준] 4673: 셀프넘버  (0) 2020.12.29
[백준] 2884: 알람 시계  (0) 2020.12.29
[백준] 2588: 곱셈  (0) 2020.12.29
[백준] 2557: 숫자의 개수  (0) 2020.12.29
복사했습니다!