아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Cows in Bed

면접 대비

시간 제한1초메모리 제한1024 MB

요약
서로 다른 N개의 브랜드 번호가 주어질 때, 모든 S_i mod K 값이 서로 다르게 되는 최소 K를 구한다.
난이도

보통10점 중 6점

유형
정수론, 수학, 해시맵, 완전 탐색
정답자
아직 제출이 없습니다

문제

FJ has N (1 ≤ N ≤ 5000) cows who sleep in stalls in a barn with K stalls numbered 0..K-1. The i-th cow has a unique brand that is a number Si (1 ≤ Si ≤ 1,000,000). Each cow knows where to sleep because she sleeps in stall number Si mod K. Of course, cows will never want to share a stall for sleeping.

Given a set of cows and their brands, determine the minimum K such that no two cows sleep in the same stall.

입력

  • Line 1: One integer: N
  • Lines 2..N+1: One integer that is a cows brand

출력

A single line with the minimum value of K on it. All legal input datasets can be solved within the allotted time.

예제1

  1. 예제 1

    입력
    5
    4
    6
    9
    10
    13
    
    예상 출력
    8