Fading Wind

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

You're competing in an outdoor paper airplane flying contest, and you want to predict how far your paper airplane will fly. Your design has a fixed factor kk, such that if the airplane's velocity is at least kk, it will rise. If its velocity is less than kk it will descend.

Here is how your paper airplane will fly:

  • You start by throwing your paper airplane with a horizontal velocity of vv at a height of hh. There is an external wind blowing with a strength of ss.

  • While h>0h > 0, repeat the following sequence:

    • Increase vv by ss. Then, decrease vv by max(1,v10)\max(1, \left\lfloor \frac{v}{10} \right\rfloor). Note that v10\left\lfloor \frac{v}{10} \right\rfloor is the value of v10\frac{v}{10}, rounded down to the nearest integer if it is not an integer.
    • If vkv \ge k, increase hh by one.
    • If 0<v<k0 < v < k, decrease hh by one. If hh is zero after the decrease, set vv to zero.
    • If v0v \le 0, set hh to zero and vv to zero.
    • Your airplane now travels horizontally by vv units.
    • If s>0s > 0, decrease it by 11.

Compute how far the paper airplane travels horizontally.

입력

The single line of input contains four integers hh, kk, vv, and ss (1h,k,v,s103)(1 \le h, k, v, s \le 10^3), where hh is your starting height, kk is your fixed factor, vv is your starting velocity, and ss is the strength of the wind.

출력

Output a single integer, which is the distance your airplane travels horizontally. It can be shown that this distance is always an integer.