아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Skills in Pills

시간 제한1초메모리 제한1024 MB

요약
n일 동안 약 A는 k일 연속 공백이 없게, 약 B는 j일 연속 공백이 없게 복용하되 같은 날 복용하지 않도록 하면서 최소 복용 횟수를 구한다.
난이도

보통10점 중 6점

유형
그리디, 수학, 정수론
정답자
아직 제출이 없습니다

문제

An unnamed protagonist of this task received amazing e-mail offers for wondrous pills that will enhance their cognitive and all other sorts of abilities. After carefully analysing all offers and side effects, he has decided that he will order 2 types of pills, let's call them AA and BB. He needs to take pill AA every kk days and pill BB every jj days. He will follow this meticulously over the next nn days.

More formally, in the next nn days, there should be no kk consecutive days where he does not take pill AA and no jj consecutive days where pill BB is not taken. However, there is a twist - the two pills are highly potent and must not be taken on the same day, lest horrible side effects should happen. Given this constraint, what is the smallest number of pills that he needs to take to meet these requirements?

입력

You are given three space-separated integers, kk, jj, and nn.

출력

Print one number - the minimum number of pills that need to be taken. It is easy to prove that a solution always exists for the given constraints.

제한

  • 2≤n≤1062 \leq n \leq 10^6
  • 2≤k,j≤n2 \leq k,j \leq n

힌트

In the first case, we can take pill A on days 22, 44, 55, and 77, and pill BB on days 33 and 66, giving the sequence .ABAABA. In the second case, the best approach is to take pills in sequence .ABAABAABA. which requires taking 9 pills.

예제3

  1. 예제 1

    입력
    2 3 8
    
    예상 출력
    6
    
  2. 예제 2

    입력
    2 3 11
    
    예상 출력
    9
    
  3. 예제 3

    입력
    3 7 100
    
    예상 출력
    48