Average Value

면접 대비

시간 제한2초메모리 제한2048 MB

요약
배열이 주어질 때, 나머지 n-1개 원소의 기하평균과 값이 같은 원소의 인덱스를 찾는다.
난이도

보통10점 중 6점

유형
수학, 정수론, 구현
정답자
아직 제출이 없습니다

문제

You are given an array aa of nn integers. Find any index ii (1≤i≤n1 \le i \le n) such that the element a_ia\_i equals to the geometric mean of all the other elements. In other words, find any index ii that satisfies the following formula: a_i=\rootn−1\of∏_k=1 k≠ina_k.a\_i = \root{n-1}\of{\prod\_{\substack{k=1 \\\ k \neq i}}^n a\_k}\text{.}

입력

The first line contains one integer nn (2≤n≤1052 \leq n \leq 10^5): the length of the array.

The second line contains nn integers a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n (a_k≥1a\_k \geq 1; the total number of digits in all numbers does not exceed 300,000300\\,000).

It is guaranteed that the answer exists for the given array.

출력

Output one integer: the index of the element that equals to geometric mean of the others items. It there are several answers, output any one of them.

예제2

  1. 예제 1

    입력
    5
    2 4 8 16 32
    
    예상 출력
    3
    
  2. 예제 2

    입력
    2
    123456789012345678901234567890 123456789012345678901234567890
    
    예상 출력
    2