Problem Statement
"NÄmec's quadratic law: how many minutes the teacher was late to the lesson, that many minutes squared he'll end the lesson earlier."
In other words, if the teacher is t minutes late (for some non-negative integer t), he should end the lesson t2 minutes early. Of course, this means the teacher can't be too late, because a lesson can't end before even starting. It is, however, possible for the teacher to arrive and end the lesson immediately (in fact, he then only arrives to tell the students that the lesson's cancelled).
You're given a
Definition
- Class:
- QuadraticLaw
- Method:
- getTime
- Parameters:
- long
- Returns:
- long
- Method signature:
- long getTime(long d)
- (be sure your method is public)
Constraints
- d will be between 1 and 1,000,000,000,000,000,000, inclusive.
Examples
1
Returns: 0
The lesson was supposed to take 1 minute. The teacher can only be 0 minutes late, in which case he ends the lesson 0 minutes early (i.e. he arrives and ends the lecture on time).
2
Returns: 1
It's possible for the teacher to be 1 minute late and end the lecture 1 minute early (so there's no lecture at all).
5
Returns: 1
6
Returns: 2
7
Returns: 2
1482
Returns: 38
1000000000000000000
Returns: 999999999
3
Returns: 1
4
Returns: 1
8
Returns: 2
9
Returns: 2
11
Returns: 2
12
Returns: 3
13
Returns: 3
14
Returns: 3
15
Returns: 3
19
Returns: 3
20
Returns: 4
21
Returns: 4
25
Returns: 4
30
Returns: 5
109
Returns: 9
110
Returns: 10
239
Returns: 14
240
Returns: 15
272
Returns: 16
273
Returns: 16
999999999000000000
Returns: 999999999
999999998999999999
Returns: 999999998
103383831633775665
Returns: 321533561
61299352584613691
Returns: 247587060
894466004015791768
Returns: 945762128
999999999500000000
Returns: 999999999
528855640288122840
Returns: 727224614
528855642979122840
Returns: 727224616
528855641389122740
Returns: 727224614
528855641389122940
Returns: 727224615
9949762070
Returns: 99747
428617
Returns: 654
237
Returns: 14
619
Returns: 24
177065240309308056
Returns: 420791207
177065240309308055
Returns: 420791206
177065240309308054
Returns: 420791206
59984731
Returns: 7744
716985016762
Returns: 846749
1662103671524136
Returns: 40768905
680794135506987356
Returns: 825102499
936977302116305825
Returns: 967975878
1234567890
Returns: 35135
31958809614643170
Returns: 178770270
999999203000158731
Returns: 999999600
99999999999999999
Returns: 316227765
500
Returns: 21
56478496
Returns: 7514
170
Returns: 12
10
Returns: 2
5789
Returns: 75
38
Returns: 5
970
Returns: 30
208
Returns: 13
23252444213212961
Returns: 152487520