luogu#P4851. yyf hates ganhuodong
yyf hates ganhuodong
Background
The unlucky guy (feiqiu) yyf knows he is too unlucky, so he starts grinding the event. yyf finally becomes a hardcore grinder (gandi), but he still wants to save as much as possible. Otherwise, if he spends too much , yyf will feel very bad about it.
Problem Description
You are given the following positive integers:
: the event gained by completing one song.
: the required to complete one song.
: the initial cap when you start grinding the event.
: the initial when you start grinding the event.
: the initial experience cap when you start grinding the event.
: the initial experience when you start grinding the event.
: the experience gained from playing one song.
: the increase in the cap when leveling up by one level.
: the increase in the experience cap when leveling up by one level.
: the remaining time until the event ends (in hours).
: your target event .
Assume yyf can play songs without spending time. Each time you play a song, you need to spend some to gain some event and some experience. yyf starts with event equal to .
automatically recovers point per hour. When reaches the cap, it will not recover automatically (you do not need to consider this situation in this problem), but it can exceed the cap using the method described later.
When experience reaches the cap, you level up. When leveling up, your cap increases and you recover “the new cap” (after the increase) points of . The recovered can exceed the cap. Any overflow experience is carried over to the next level-up, and the required experience for the next level-up (the experience cap) will increase.
You can spend one at any time to gain equal to your current cap (this can exceed the cap).
Your goal is to obtain event greater than or equal to . Find the minimum number of you need to spend.
Formally, your initial can be considered as . You have two operations:
- Let the experience before the operation be , the cap be , the current be (you can perform operation if and only if ), and the experience cap be . After this operation, event increases by .
- If , then the remaining becomes , the experience becomes , the cap increases by , and the experience cap increases by .
- Otherwise, the remaining becomes , and the experience becomes .
- Let the cap before the operation be and the current be . After this operation, the remaining becomes .
Your goal is to make your event greater than or equal to . Find the minimum number of times you need to perform operation .
Since playing songs does not take time, you can play any number of songs at the exact moment the event ends, i.e. you can perform operation any number of times. Therefore, the initial can be considered as .
Input Format
A single line containing the above positive integers, with meanings as described above.
Output Format
A single positive integer, representing the minimum number of that must be spent.
9 7 46 6 114 50 17 6 18 11 9118
7
Hint
Translated by ChatGPT 5