Statistics

Problem Statement for "ThreeDigits"

Problem Statement

Find the last three digits before the decimal point and the first three digits after the decimal point in the number XY / Z.

Return your answer formatted as a String. The String must always include the decimal point and exactly three digits after the decimal point. If the number has fewer than three digits before the decimal point, only include those digits, do not pad the number with zeros.

Definition

Class:
ThreeDigits
Method:
calculate
Parameters:
int, int, int
Returns:
String
Method signature:
String calculate(int X, int Y, int Z)
(be sure your method is public)

Notes

  • Do not perform any rounding, just output the correct digits in the required places. E.g., if the exact number is 123.4567, the correct output is "123.456", not "123.457".
  • For numbers with finite decimal expansions we are using the more natural form where all the following digits are zeros. For example, if the exact number is 123.4, only "123.400" is a correct answer, "123.399" (as a prefix of 123.9999999...) will be rejected.

Constraints

  • X will be between 0 and 1000000000 (1 billion).
  • Y will be between 0 and 1000000000 (1 billion).
  • Z will be between 1 and 1000000 (1 million).
  • Either X or Y will be non-zero.

Examples

  1. 3

    5

    7

    Returns: "34.714"

    In this example, since the value of XY / Z = 243 / 7 = 34.7142857..., you should return "34.714".

  2. 4

    7

    32

    Returns: "512.000"

    In this example, since the value of XY / Z = 16384 / 32 = 512.0000000..., you should return "512.000".

  3. 3

    2

    36

    Returns: "0.250"

    In this example, since the value of XY / Z = 9 / 36 = 0.2500000..., you should return "0.250". Note that the "0" before the decimal point is mandatory, the return value ".250" will be rejected.

  4. 7

    4

    47

    Returns: "51.085"

    In this example, since the value of XY / Z = 2401 / 47 = 51.0851063..., you should return "51.085".

  5. 13

    6

    479

    Returns: "076.845"

    13^6 / 479 = 10076.84551148..., so the correct answer is "076.845". Note that this number has more than three digits before its decimal point, so the return value must start "076" and not just "76".

  6. 1234

    56789

    123456

    Returns: "133.942"

    The value of 123456789 / 123456 has 175,548 digits before the decimal point. The number begins 4028022093412... and around its decimal point we have the digits ...7339915133.9429756350...

  7. 999999999

    128

    1000000

    Returns: "000.000"

    In this example, both of the last three digits before the decimal point and the first three digits after the decimal point are "000", even though the value is not an integer.

  8. 0

    1

    1

    Returns: "0.000"

  9. 1

    0

    1

    Returns: "1.000"

  10. 1

    1

    1

    Returns: "1.000"

  11. 999999

    999999

    999999

    Returns: "001.000"

  12. 999999

    999999

    1000000

    Returns: "998.999"

  13. 999999

    1000000

    999999

    Returns: "999.000"

  14. 999999

    1000000

    1000000

    Returns: "000.000"

  15. 1000000

    999999

    999999

    Returns: "001.000"

  16. 1000000

    999999

    1000000

    Returns: "000.000"

  17. 1000000

    1000000

    999999

    Returns: "001.000"

  18. 1000000

    1000000

    1000000

    Returns: "000.000"

  19. 999999999

    999999999

    999999

    Returns: "360.640"

  20. 999999999

    999999999

    1000000

    Returns: "999.999"

  21. 999999999

    1000000000

    999999

    Returns: "279.719"

  22. 999999999

    1000000000

    1000000

    Returns: "000.000"

  23. 1000000000

    999999999

    999999

    Returns: "000.001"

  24. 1000000000

    999999999

    1000000

    Returns: "000.000"

  25. 1000000000

    1000000000

    999999

    Returns: "001.000"

  26. 1000000000

    1000000000

    1000000

    Returns: "000.000"

  27. 0

    987654321

    1

    Returns: "0.000"

  28. 0

    789456123

    142857

    Returns: "0.000"

  29. 1

    147258369

    1

    Returns: "1.000"

  30. 1

    492357816

    714285

    Returns: "0.000"

  31. 499999837

    0

    1

    Returns: "1.000"

  32. 314159265

    0

    358979

    Returns: "0.000"

  33. 271828182

    1

    1

    Returns: "182.000"

  34. 914831750

    1

    867413

    Returns: "054.666"

  35. 999999999

    127

    1000000

    Returns: "999.999"

  36. 48828125

    1

    25

    Returns: "125.000"

  37. 48828125

    1

    390625

    Returns: "125.000"

  38. 244140625

    1

    25

    Returns: "625.000"

  39. 244140625

    1

    390625

    Returns: "625.000"

  40. 48828125

    999999911

    25

    Returns: "125.000"

  41. 48828125

    999999970

    390625

    Returns: "625.000"

  42. 244140625

    1000000000

    25

    Returns: "625.000"

  43. 244140625

    999999997

    390625

    Returns: "625.000"

  44. 40353607

    919191919

    16

    Returns: "671.437"

  45. 387420489

    191919191

    524288

    Returns: "533.195"

  46. 781495678

    279580491

    1000000

    Returns: "875.612"

  47. 933670579

    712267053

    839829

    Returns: "856.731"

  48. 692292671

    826872570

    789286

    Returns: "828.486"

  49. 173234493

    581695344

    976757

    Returns: "201.892"

  50. 135037361

    331315596

    700996

    Returns: "559.498"

  51. 369164299

    489096052

    793016

    Returns: "282.875"

  52. 11

    5

    161051

    Returns: "1.000"

  53. 30

    6

    729000

    Returns: "000.000"

  54. 473585400

    600549906

    69120

    Returns: "000.000"

  55. 483095378

    537940855

    499267

    Returns: "000.001"

  56. 156005986

    33609246

    278613

    Returns: "000.006"

  57. 683852925

    585283279

    155730

    Returns: "000.084"

  58. 294017191

    874442985

    392561

    Returns: "000.451"

  59. 970358583

    691114871

    868751

    Returns: "001.007"

  60. 894495930

    248935242

    456552

    Returns: "008.516"

  61. 593955301

    183585018

    825874

    Returns: "023.700"

  62. 688015761

    174464831

    374949

    Returns: "092.046"

  63. 443175639

    941046821

    522571

    Returns: "137.000"

  64. 218059260

    957032400

    847238

    Returns: "290.817"

  65. 119174760

    259733573

    229372

    Returns: "418.516"

  66. 208040792

    515291777

    241276

    Returns: "499.999"

  67. 931899193

    399378588

    8120

    Returns: "500.000"

  68. 426367536

    515074506

    178052

    Returns: "500.001"

  69. 481801493

    390332771

    331106

    Returns: "741.586"

  70. 20124380

    885686432

    100092

    Returns: "869.120"

  71. 14169850

    538166388

    541082

    Returns: "946.008"

  72. 504279556

    349057954

    797940

    Returns: "992.654"

  73. 753706466

    328713155

    462804

    Returns: "992.654"

  74. 653349589

    326440701

    31439

    Returns: "999.000"

  75. 73256806

    250302305

    92522

    Returns: "999.413"

  76. 314689428

    265821682

    103555

    Returns: "999.909"

  77. 644751291

    164517547

    32503

    Returns: "999.991"

  78. 260236668

    67882576

    740401

    Returns: "999.999"

  79. 7

    2

    9

    Returns: "5.444"

  80. 8

    9

    192

    Returns: "050.666"

  81. 5

    8

    221859

    Returns: "1.760"

  82. 2

    8991

    6

    Returns: "741.333"

  83. 3

    4732

    932

    Returns: "615.709"

  84. 5

    4020

    824929

    Returns: "512.420"

  85. 6

    597924709

    5

    Returns: "739.200"

  86. 4

    883056588

    448

    Returns: "489.142"

  87. 9

    230199297

    694587

    Returns: "262.822"

  88. 4767

    3

    3

    Returns: "221.000"

  89. 2562

    4

    358

    Returns: "950.659"

  90. 8903

    3

    727769

    Returns: "651.263"

  91. 7962

    6138

    8

    Returns: "288.000"

  92. 3153

    7477

    949

    Returns: "432.363"

  93. 3453

    7057

    502838

    Returns: "248.519"

  94. 6516

    619292611

    7

    Returns: "630.857"

  95. 9091

    700314766

    912

    Returns: "833.816"

  96. 9325

    310998747

    626127

    Returns: "198.198"

  97. 981792208

    9

    5

    Returns: "905.600"

  98. 474802932

    8

    658

    Returns: "640.389"

  99. 101068112

    7

    847121

    Returns: "860.989"

  100. 404377230

    5273

    5

    Returns: "000.000"

  101. 620554782

    5295

    881

    Returns: "430.837"

  102. 724923330

    8332

    545052

    Returns: "211.972"

  103. 858395771

    255899262

    7

    Returns: "520.142"

  104. 801457279

    878648562

    698

    Returns: "004.356"

  105. 578309656

    841913102

    893865

    Returns: "374.923"

  106. 12347

    56789

    123456

    Returns: "091.357"

  107. 99999999

    99999999

    99999

    Returns: "903.349"

  108. 999999937

    799999931

    14983

    Returns: "198.686"

  109. 987654321

    987654321

    987654

    Returns: "382.752"

  110. 139999

    1

    100000

    Returns: "1.399"

  111. 13

    0

    1

    Returns: "1.000"

  112. 1

    18763

    24634

    Returns: "0.000"

  113. 0

    1000000000

    999997

    Returns: "0.000"

  114. 301632

    22

    460800

    Returns: "353.280"

  115. 0

    100

    1

    Returns: "0.000"

  116. 987654321

    987654321

    1337

    Returns: "514.376"

  117. 99999

    1

    1000

    Returns: "99.999"

  118. 2

    10

    1

    Returns: "024.000"

  119. 12345678

    10000000

    65536

    Returns: "816.000"


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: