문제 출처:https://www.acmicpc.net/problem/3052
3052번: 나머지
각 수를 42로 나눈 나머지는 39, 40, 41, 0, 1, 2, 40, 41, 0, 1이다. 서로 다른 값은 6개가 있다.
www.acmicpc.net

코드는 다음과 같습니다:
#include <iostream>
using namespace std ;
int main(){
ios::sync_with_stdio(false) ;
cin.tie(NULL) ; cout.tie(NULL) ;
int remainder[42] = {0, }, temp, cnt = 0 ;
for(int i = 0 ; i < 10 ; i++){
cin >> temp ;
temp %= 42 ;
remainder[temp] += 1 ;
}
for(int i = 0 ; i < 42 ; i++)
if(remainder[i] != 0)
cnt += 1 ;
cout << cnt << endl ;
return 0 ;
}
해당 문제는 Github에서도 보실 수 있습니다:
https://github.com/gurcks8989/CodingTest/blob/master/BackJoon/HPS/P3052_Remainder.cpp
GitHub - gurcks8989/CodingTest: CodingTest_study_with_c++
CodingTest_study_with_c++. Contribute to gurcks8989/CodingTest development by creating an account on GitHub.
github.com
훈수 및 조언은 언제든 환영입니다.
문제 출처:https://www.acmicpc.net/problem/3052
3052번: 나머지
각 수를 42로 나눈 나머지는 39, 40, 41, 0, 1, 2, 40, 41, 0, 1이다. 서로 다른 값은 6개가 있다.
www.acmicpc.net

코드는 다음과 같습니다:
#include <iostream>
using namespace std ;
int main(){
ios::sync_with_stdio(false) ;
cin.tie(NULL) ; cout.tie(NULL) ;
int remainder[42] = {0, }, temp, cnt = 0 ;
for(int i = 0 ; i < 10 ; i++){
cin >> temp ;
temp %= 42 ;
remainder[temp] += 1 ;
}
for(int i = 0 ; i < 42 ; i++)
if(remainder[i] != 0)
cnt += 1 ;
cout << cnt << endl ;
return 0 ;
}
해당 문제는 Github에서도 보실 수 있습니다:
https://github.com/gurcks8989/CodingTest/blob/master/BackJoon/HPS/P3052_Remainder.cpp
GitHub - gurcks8989/CodingTest: CodingTest_study_with_c++
CodingTest_study_with_c++. Contribute to gurcks8989/CodingTest development by creating an account on GitHub.
github.com
훈수 및 조언은 언제든 환영입니다.