본문 바로가기
공부/코딩테스트

백준: 18301번 Rats (Python3)

by 혼밥맨 2022. 7. 30.
반응형

백준: 18301번 Rats (Python3)

Rats 성공다국어

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB 3363 2699 2600 80.670%

문제

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.

쥐의 음력 설을 축하하기 위해 Douglas는 자신의 지역에 살고 있는 쥐의 수를 세기로 결정합니다. 쥐가 잘 숨겨져 있기 때문에 모든 쥐를 찾는 것은 불가능합니다. 그러나 새해 첫날, Douglas는 n1마리의 쥐를 잡는 데 성공하고, 쥐를 풀어주기 전에 각각 귀표로 표시를 합니다. 새해 두 번째 날, Douglas는 n2마리의 쥐를 잡고 그 중 n12마리가 첫날에 표시되어 있는 것을 관찰합니다.

Douglas는 자신의 영역에 있는 총 쥐 수를 추정하는 데 도움을 요청합니다. 통계 교과서를 찾아보면 다음과 같이 주어진 채프먼 추정기 N을 사용할 것을 제안합니다.

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

여기서 ⌊x⌋는 실수 x의 바닥, 즉 x보다 작거나 같은 가장 가까운 정수입니다.

입력

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

입력은 공백으로 구분된 세 개의 정수(n1, n2, n12)가 있는 한 줄로 구성됩니다.

출력

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

출력에는 단일 정수 N이 있는 단일 행이 포함되어야 합니다.

제한

  • 0 ≤ n1, n2 ≤ 10 000;
  • 0 ≤ n12 ≤ min(n1, n2).

예제 입력 1

15 18 11

예제 출력 1

24

답안

1
2
a, b, c = map(int, input().split())
print(int( (a+1)*(b+1)/(c+1)-1 ))
cs

반응형

댓글