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 loveca\mathrm{loveca} as possible. Otherwise, if he spends too much loveca\mathrm{loveca}, yyf will feel very bad about it.

Problem Description

You are given the following 1111 positive integers:

aa: the event pt\mathrm{pt} gained by completing one song.

bb: the LP\mathrm{LP} required to complete one song.

cc: the initial LP\mathrm{LP} cap when you start grinding the event.

dd: the initial LP\mathrm{LP} when you start grinding the event.

ee: the initial experience cap when you start grinding the event.

ff: the initial experience when you start grinding the event.

gg: the experience gained from playing one song.

hh: the increase in the LP\mathrm{LP} cap when leveling up by one level.

kk: the increase in the experience cap when leveling up by one level.

xx: the remaining time until the event ends (in hours).

yy: your target event pt\mathrm{pt}.

Assume yyf can play songs without spending time. Each time you play a song, you need to spend some LP\mathrm{LP} to gain some event pt\mathrm{pt} and some experience. yyf starts with event pt\mathrm{pt} equal to 00.

LP\mathrm{LP} automatically recovers 11 point per hour. When LP\mathrm{LP} 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 LP\mathrm{LP} cap increases and you recover “the new LP\mathrm{LP} cap” (after the increase) points of LP\mathrm{LP}. The recovered LP\mathrm{LP} can exceed the LP\mathrm{LP} 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 loveca\mathrm{loveca} at any time to gain LP\mathrm{LP} equal to your current LP\mathrm{LP} cap (this can exceed the cap).

Your goal is to obtain event pt\mathrm{pt} greater than or equal to yy. Find the minimum number of loveca\mathrm{loveca} you need to spend.

Formally, your initial LP\mathrm{LP} can be considered as d+xd+x. You have two operations:

  1. Let the experience before the operation be exp\mathrm{exp}, the LP\mathrm{LP} cap be LPmax\mathrm{LPmax}, the current LP\mathrm{LP} be ll (you can perform operation 11 if and only if lbl \ge b), and the experience cap be EXPmax\mathrm{EXPmax}. After this operation, event pt\mathrm{pt} increases by aa.
  • If exp+gEXPmax\mathrm{exp+g \ge EXPmax}, then the remaining LP\mathrm{LP} becomes lb+LPmax+hl-b+\mathrm{LPmax}+h, the experience becomes (exp+g)modEXPmax\mathrm{(exp+g)\bmod EXPmax}, the LP\mathrm{LP} cap increases by hh, and the experience cap increases by kk.
  • Otherwise, the remaining LP\mathrm{LP} becomes lbl-b, and the experience becomes exp+g\mathrm{exp+g}.
  1. Let the LP\mathrm{LP} cap before the operation be LPmax\mathrm{LPmax} and the current LP\mathrm{LP} be ll. After this operation, the remaining LP\mathrm{LP} becomes LPmax+l\mathrm{LPmax}+l.

Your goal is to make your event pt\mathrm{pt} greater than or equal to yy. Find the minimum number of times you need to perform operation 22.

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 11 any number of times. Therefore, the initial LP\mathrm{LP} can be considered as d+xd+x.

Input Format

A single line containing the above 1111 positive integers, with meanings as described above.

Output Format

A single positive integer, representing the minimum number of loveca\mathrm{loveca} that must be spent.

9 7 46 6 114 50 17 6 18 11 9118
7

Hint

a[1,10]a∈[1,10]

b[5,20]b∈[5,20]

c[30,50]c∈[30,50]

d[5,10]d∈[5,10]

e[100,200]e∈[100,200]

f[1,50]f∈[1,50]

g[10,20]g∈[10,20]

h[5,10]h∈[5,10]

k[10,20]k∈[10,20]

x[10,15]x∈[10,15]

y[5000,10000]y∈[5000,10000]

Translated by ChatGPT 5