1 분 소요

1. 문제

[Bronze V] Rats - 18301

문제 링크

성능 요약

메모리: 30864 KB, 시간: 80 ms

분류

사칙연산(arithmetic), 수학(math)

문제 설명

To celebrate the Lunar New Year of the Rat, Douglas decides to count the number of rats living in his area. It is impossible for him to find all rats, as they tend to be well hidden. However, on the first day of the new year, Douglas manages to capture n1 rats, and marks each of them with an ear tag before releasing them. On the second day of the new year, Douglas captures n2 rats, and observes that n12 of them had been marked during the first day.

Douglas is asking for your help to estimate the total number of rats in his area. Looking up in your statistics textbook, you propose using the Chapman estimator N, given by:

N := ⌊(n1 + 1)(n2 + 1)/(n12 + 1) - 1⌋

where ⌊x⌋ is the floor of a real number x, i.e., the closest integer less than or equal to x.

입력

The input consists of a single line, with three space-separated integers: n1, n2, n12, in that order.

출력

The output should contain a single line with the single integer N.

출처: 백준, https://https://www.acmicpc.net/

2. 해결방법 시간복잡도

  1. 단순 코딩 O(1)

3. 문제 해결 및 코드


  • 주석을 참고하면서 이해를 돕습니다.

4. 알고리즘 및 해설

  1. 각각의 값들을 받은 이후 문제에서 제시한 공식을 사용해서 출력해준다.
    • 문제에서 제시한 공식 N := ⌊(n 1 + 1)(n 2 + 1)/(n 12 + 1) - 1⌋