No.51 A Matter of Motivation
タグ : / 解いたユーザー数 772
作問者 :
Problem Statement
Thomas's motivation can be calculated easily.
Let \(D\) be the number of days remaining until the deadline,
and let \(W\) be the remaining amount of work. Then his motivation for that day is \(\frac{W}{D^2} \).
The value of the motivation with its fractional part truncated becomes the amount of work done on that day.
Thomas is wondering how much work he will have to do on the final day.
Given the amount of work \(W\) assigned on the first day and the number of days \(D\) until the deadline,
please calculate for Thomas how much work there will be on the last day.
(Pay attention to the constraints on the values.)
Input
\(W\) \(D\)
The first line contains an integer \(W (1\le W \le 10^5 )\), the amount of work, and
the second line contains an integer \(D (1 \le D \le 10^5 ) \), the number of days until the deadline.
Output
Output the amount of work on the last day.
Sample
Sample 1
Input
30 5
Output
19
The amount of work is 30, and the number of days until the deadline is 5.
Here, the motivation on day 1 is \( 30/5^2 =1.2\), so the amount of work on this day is \( 1\).
The motivation on day 2 is \( 29/4^2 =1.8125\), so the amount of work on this day is also \( 1\).
The motivation on day 3 is \( 28/3^2 =3.111..\), so the amount of work on this day is \( 3\).
The motivation on day 4 is \( 25/2^2 =6.25\), so the amount of work on this day is \( 6\).
The motivation on day 5 is \( 19/1^2 =19\), so the amount of work on this day is \( 19\).
That is, the amount of work done on the last day is \( 19\).
Sample 2
Input
100 2
Output
75
The motivation on day 1 is \( 100/2^2 =25\), so the amount of work on this day is \(25\).
The motivation on day 2 is \( 75/1^2 =75\), so the amount of work on this day is \(75\).
The amount of work done on the final day is \(75\).
Sample 3
Input
100000 1
Output
100000
The work amount of \(100000\) was finished in one day.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。