hsminnnn

[ 백준 BAEKJOON ] 3052번 : 나머지 ( C언어 ) 본문

백준 문제풀이

[ 백준 BAEKJOON ] 3052번 : 나머지 ( C언어 )

hsminnnn 2023. 3. 12. 14:23

https://www.acmicpc.net/problem/3052

 

3052번: 나머지

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

www.acmicpc.net

 

 

 

 

 

문제

 

 

 

 

 

 

 

소스 코드
#include <stdio.h>

int main(void) {
    
    int input, result=0;
    int remain[10];
    
    for(int i=0; i<10; i++) {
        scanf("%d", &input);
        remain[i] = (input % 42);
    }
    
    for(int i=0; i<10; i++) {
        int count=0; 
        for(int j=i+1; j<10; j++) { 
            if(remain[i] == remain[j]) count++;
        }
        if (count == 0) result++; 
    }
    
   printf("%d", result);
}

 

 

 

 

 

 

결과

 

 

 

 

Comments