시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 143 13 13 20.968%

문제

선영이와 남자친구의 2주년이 얼마 남지 않았다. 선영이는 그를 위해 특별한 것을 사주려고 한다. 남자친구는 나무에 관심이 매우 많다. 하지만, 선영이는 나무는 선물로 매우 크다고 생각한다. 따라서, 꽃을 사주려고 한다.

선영이는 모든 꽃에는 그 꽃과 가장 잘 어울리는 꽃병의 부피가 있다고 생각한다. 선영이는 꽃병을 구매하기 위해 인터넷 쇼핑몰에 들어갔다. 쇼핑몰에는 꽃병의 사진과 윤곽 함수가 적혀져 있다. 가장 적합한 꽃병을 찾는 프로그램을 작성하시오.

꽃병의 윤곽은 함수 f(x) = a・e-x2+ b・√x로 나타낼 수 있다. 여기서 x는 꽃병의 바닥과 떨어진 수직 거리이다. 꽃병은 이 함수를 x축에 대해서 회전시킨 모양이다. 꽃병의 높이는 h이다.

서로 다른 두 꽃병의 부피의 차이는 적어도 10-4이다. 또, 서로 다른 두 꽃병과 선영이가 찾는 꽃병의 부피의 차이도 적어도 10-4 만큼 차이난다.

입력

첫째 줄에 선영이가 찾는 꽃병의 부피 1 < V ≤ 105 와 쇼핑몰에 올라와 있는 꽃병의 수 0 < N ≤ 5 이 주어진다.

다음 N개 줄에는 문제의 함수에 해당하는 a, b, h가 주어진다. (1 ≤ a, b, h ≤ 10)

예제의 경우에 두 꽃병의 부피는 34.72348, 21.77966이다.

출력

선영이가 찾는 꽃병과 부피 차이가 적은 꽃병의 인덱스를 출력한다. 첫 번째 꽃병의 인덱스는 0이다.

예제 입력 1

25.0 2
1.0 2.0 2.0
2.0 1.0 2.0

예제 출력 1

1

힌트

W3sicHJvYmxlbV9pZCI6IjkyMDYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIwOThcdWJiMzQgXHViOWQwXHVhY2UwIFx1YWY0MyIsImRlc2NyaXB0aW9uIjoiPHA+XHVjMTIwXHVjNjAxXHVjNzc0XHVjNjQwIFx1YjBhOF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