반응형

문제 출처 :


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



알고리즘 분석 :


문제 해결에 필요한 사항

1. 구현


i가 정답이 되는 수라 가정했을 때, 1부터 계속 증가시키며 5개의 수중 3개가 i % arr[j]에 해당하는지 파악하면 되는 문제이다.


간단한 문제이지만 어떻게 푸느냐에 따라 다르게 볼 수 있는 문제인 듯 하다.













소스 코드 : 


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
#include <iostream>
#include <cstdio>
 
using namespace std;
 
int main()
{
    int arr[5];
    for (int i = 0; i < 5; i++)
        scanf("%d"&arr[i]);
 
    for (int i = 1;; i++)
    {
        int cnt = 0;
        for (int j = 0; j < 5; j++)
            if (i % arr[j] == 0)
            {
                cnt++;
                if (cnt >= 3)
                {
                    cout << i;
                    return 0;
                }
            }
    }
    return 0;
 
}
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus


반응형

'Applied > 알고리즘 문제풀이' 카테고리의 다른 글

[1406번] 에디터  (0) 2017.06.29
[3053번] 택시 기하학  (0) 2017.06.28
[1926번] 그림  (0) 2017.06.22
[1057번] 토너먼트  (0) 2017.06.22
[1246번] 온라인 판매  (0) 2017.06.20