Logo
(追記) (追記ここまで)

18020번 - Cocoa Coalition 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB192685938.065%

문제

Alice and Bob decide to share a chocolate bar, which is an n by m rectangular grid of chocolate cells. They decide that Alice should get a < n · m pieces and that Bob should get b = n · m − a pieces. To split the chocolate bar, they repeatedly take a single piece of chocolate and break it either horizontally or vertically, creating two smaller pieces of chocolate. See Figure C.1 for an example.

What is the minimum number of splits that Alice and Bob need to perform in order to split the n-by-m chocolate bar into two piles consisting of a and b chocolate cells?

Figure C.1: Illustration of a solution to Sample Input 2, showing the original 10-by-10 chocolate bar split three times into pieces of size 10-by-2, 10-by-5, 3-by-3 and 7-by-3. Giving Alice the 10-by-5 and 7-by-3 pieces, she gets a total of 50 + 21 = 71 chocolate cells.

입력

The input consists of a single line, containing the three integers n, m and a (1 ≤ n, m ≤ 106, 1 ≤ a < n · m).

출력

Output the minimum number of splits needed to achieve the desired division of chocolate.

제한

예제 입력 1

3 10 9

예제 출력 1

1

예제 입력 2

10 10 71

예제 출력 2

3

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Nordic Collegiate Programming Contest > NCPC 2019 C번

  • 문제를 만든 사람: Pål Grønås Drange
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /