시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB50922371182347.648%

문제

학생들은 3주가 지난 기념으로 매점에서 1월 1일이 지나 싸게 파는 폭죽을 사서 터뜨리고 있다.

폭죽쇼를 하는 동안 N명의 학생들이 폭죽을 터뜨린다. 그리고 이 N명의 학생은 각각 일정한 주기로 폭죽을 터뜨린다. 물론 이 주기는 학생들마다 같을 수도, 다를 수도 있다. 그리고 우리는 초 단위로 관찰을 하고, 폭죽 역시 초 단위로 터진다.

폭죽쇼가 끝날 때까지 얼마나 많은 시간동안 밤하늘에 폭죽이 터지는 것을 볼 수 있는지 궁금해 하는 조교를 도와주자.

입력

첫 줄에 폭죽을 터뜨리는 학생의 수 N(1 ≤ N ≤ 100)과 폭죽쇼가 끝나는 시간 C(1 ≤ C ≤ 2,000,000)가 주어진다. 그 다음 N개의 줄에는 학생들이 폭죽을 터뜨리는 주기가 한 줄에 하나씩 주어진다. 주기는 1보다 크거나 같고, C보다 작거나 같은 자연수이다.

출력

폭죽쇼가 시작되고 끝날 때까지 밤하늘에 폭죽을 볼 수 있는 총 시간을 출력한다.

예제 입력 1

2 20
4
6

예제 출력 1

7

힌트

                                    2                        
            1     2     1           1           1     2     1
0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
            1     2     3           4           5     6     7

위의 그림에서 1,2가 쓰여있는 4, 6, 8, 12, 16, 18, 20초에 폭죽이 밤 하늘에 터진다. 단 12초에는 두 폭죽이 동시에 하늘에 터지지만 한번으로 세는 것에 주의하자.

W3sicHJvYmxlbV9pZCI6IjE3NzMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzZWRcdWM4ZmRcdWMxZmMiLCJkZXNjcmlwdGlvbiI6IjxwPlx1ZDU1OVx1YzBkZFx1YjRlNFx1Yzc0MCAzXHVjOGZjXHVhYzAwIFx1YzljMFx1YjA5YyBcdWFlMzBcdWIxNTBcdWM3M2NcdWI4NWMgXHViOWU0XHVjODEwXHVj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sZW1fbGFuZ190Y29kZSI6IkVuZ2xpc2gifV0=

출처

Olympiad > USA Computing Olympiad > 2006-2007 Season > USACO March 2007 Contest > Bronze 1번

  • 문제를 번역한 사람: author6
  • 데이터를 추가한 사람: djm03178
  • 문제의 오타를 찾은 사람: sunhong