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

26196번 - Skills in Pills 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB107463847.500%

문제

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 $A$ and $B$. He needs to take pill $A$ every $k$ days and pill $B$ every $j$ days. He will follow this meticulously over the next $n$ days.

More formally, in the next $n$ days, there should be no $k$ consecutive days where he does not take pill $A$ and no $j$ consecutive days where pill $B$ 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, $k,ドル $j,ドル and $n$.

출력

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ドル \leq n \leq 10^6$
  • 2ドル \leq k,j \leq n$

예제 입력 1

2 3 8

예제 출력 1

6

예제 입력 2

2 3 11

예제 출력 2

9

예제 입력 3

3 7 100

예제 출력 3

48

힌트

In the first case, we can take pill A on days 2ドル,ドル 4ドル,ドル 5ドル,ドル and 7ドル,ドル and pill $B$ on days 3ドル$ and 6ドル,ドル giving the sequence .ABAABA. In the second case, the best approach is to take pills in sequence .ABAABAABA. which requires taking 9 pills.

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2022 K번

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

출처

대학교 대회

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

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