Statistics

Problem Statement for "QuadraticLaw"

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 long d. The lesson was supposed to take d minutes. Compute and return the largest non-negative integer t such that the teacher can be t minutes late.

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. 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. 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).

  3. 5

    Returns: 1

  4. 6

    Returns: 2

  5. 7

    Returns: 2

  6. 1482

    Returns: 38

  7. 1000000000000000000

    Returns: 999999999

  8. 3

    Returns: 1

  9. 4

    Returns: 1

  10. 8

    Returns: 2

  11. 9

    Returns: 2

  12. 11

    Returns: 2

  13. 12

    Returns: 3

  14. 13

    Returns: 3

  15. 14

    Returns: 3

  16. 15

    Returns: 3

  17. 19

    Returns: 3

  18. 20

    Returns: 4

  19. 21

    Returns: 4

  20. 25

    Returns: 4

  21. 30

    Returns: 5

  22. 109

    Returns: 9

  23. 110

    Returns: 10

  24. 239

    Returns: 14

  25. 240

    Returns: 15

  26. 272

    Returns: 16

  27. 273

    Returns: 16

  28. 999999999000000000

    Returns: 999999999

  29. 999999998999999999

    Returns: 999999998

  30. 103383831633775665

    Returns: 321533561

  31. 61299352584613691

    Returns: 247587060

  32. 894466004015791768

    Returns: 945762128

  33. 999999999500000000

    Returns: 999999999

  34. 528855640288122840

    Returns: 727224614

  35. 528855642979122840

    Returns: 727224616

  36. 528855641389122740

    Returns: 727224614

  37. 528855641389122940

    Returns: 727224615

  38. 9949762070

    Returns: 99747

  39. 428617

    Returns: 654

  40. 237

    Returns: 14

  41. 619

    Returns: 24

  42. 177065240309308056

    Returns: 420791207

  43. 177065240309308055

    Returns: 420791206

  44. 177065240309308054

    Returns: 420791206

  45. 59984731

    Returns: 7744

  46. 716985016762

    Returns: 846749

  47. 1662103671524136

    Returns: 40768905

  48. 680794135506987356

    Returns: 825102499

  49. 936977302116305825

    Returns: 967975878

  50. 1234567890

    Returns: 35135

  51. 31958809614643170

    Returns: 178770270

  52. 999999203000158731

    Returns: 999999600

  53. 99999999999999999

    Returns: 316227765

  54. 500

    Returns: 21

  55. 56478496

    Returns: 7514

  56. 170

    Returns: 12

  57. 10

    Returns: 2

  58. 5789

    Returns: 75

  59. 38

    Returns: 5

  60. 970

    Returns: 30

  61. 208

    Returns: 13

  62. 23252444213212961

    Returns: 152487520


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: