Statistics

Problem Statement for "RandomColoringDiv2"

Problem Statement

Little Arthur has a new frisbee and he would like to color it. A frisbee has the shape of a disc. Arthur will color the disc using two colors: one for the top side, one for the bottom side.

Each color is defined by three integer components: R, G, and B (meaning red, green, and blue, respectively), where 0 <= R < maxR, 0 <= G < maxG, and 0 <= B < maxB. It is known that Arthur can use any of the maxR*maxG*maxB possible colors.

Arthur is going to perform the coloring in the following way:
  • In the first step, he will color the top side of the frisbee using the color (startR, startG, startB).
  • In the second step, he will color the bottom side of the frisbee using a color that makes a good transition from the first color. (This is explained below.)

A transition from color (R, G, B) to color (R', G', B') is called good if all components differ by at most d2 units (formally, |R - R'| <= d2, |G - G'| <= d2, |B - B'| <= d2) and at least one component differs by at least d1 units (formally, at least one of the conditions |R - R'| >= d1, |G - G'| >= d1, |B - B'| >= d1 holds). Intuitively, a transition between two colors is called good if they are neither too similar, nor too different.

After coloring the top side Arthur is wondering how many different options there are now for the color of the bottom side of the frisbee.

Given ints maxR, maxG, maxB, startR, startG, startB, d1, and d2, return the number of valid colors that make a good transition from the color (startR, startG, startB).

Definition

Class:
RandomColoringDiv2
Method:
getCount
Parameters:
int, int, int, int, int, int, int, int
Returns:
int
Method signature:
int getCount(int maxR, int maxG, int maxB, int startR, int startG, int startB, int d1, int d2)
(be sure your method is public)

Constraints

  • maxR, maxG and maxB will each be between 1 and 100, inclusive.
  • startR will be between 0 and maxR-1, inclusive.
  • startG will be between 0 and maxG-1, inclusive.
  • startB will be between 0 and maxB-1, inclusive.
  • d1 and d2 will each be between 0 and 100, inclusive.
  • d1 will be less than or equal to d2.

Examples

  1. 5

    1

    1

    2

    0

    0

    0

    1

    Returns: 3

    Only the R component can change here. It has to change by at least 0 and at most 1. Thus the colors that make a good transition from color (2, 0, 0) here are (1, 0, 0), (2, 0, 0), and (3, 0, 0).

  2. 4

    2

    2

    0

    0

    0

    3

    3

    Returns: 4

    Colors that make a good transition from color (0, 0, 0) here are (3, 0, 0), (3, 0, 1), (3, 1, 0), and (3, 1, 1).

  3. 4

    2

    2

    0

    0

    0

    5

    5

    Returns: 0

    At least one component has to change by 5. There exists no color that makes a good transition from color (0, 0, 0) within the respective maxR, maxG, maxB constraints.

  4. 6

    9

    10

    1

    2

    3

    0

    10

    Returns: 540

    All valid colors make a good transition from color (1, 2, 3).

  5. 6

    9

    10

    1

    2

    3

    4

    10

    Returns: 330

  6. 100

    100

    100

    0

    0

    0

    0

    100

    Returns: 1000000

  7. 100

    100

    100

    99

    0

    0

    1

    100

    Returns: 999999

  8. 100

    100

    100

    0

    99

    0

    2

    100

    Returns: 999992

  9. 100

    100

    100

    0

    0

    99

    3

    40

    Returns: 68894

  10. 100

    100

    100

    99

    0

    99

    9

    30

    Returns: 29062

  11. 100

    100

    100

    99

    99

    99

    10

    10

    Returns: 331

  12. 100

    100

    100

    99

    99

    99

    20

    21

    Returns: 2648

  13. 100

    100

    100

    3

    4

    5

    0

    100

    Returns: 1000000

  14. 100

    100

    100

    2

    6

    4

    1

    100

    Returns: 999999

  15. 100

    100

    100

    89

    3

    99

    2

    100

    Returns: 999982

  16. 100

    100

    100

    95

    90

    7

    3

    40

    Returns: 107875

  17. 100

    100

    100

    3

    1

    84

    10

    10

    Returns: 811

  18. 100

    100

    100

    3

    1

    84

    20

    20

    Returns: 2103

  19. 100

    100

    100

    91

    5

    94

    9

    30

    Returns: 47212

  20. 100

    100

    100

    50

    50

    50

    0

    100

    Returns: 1000000

  21. 100

    100

    100

    49

    50

    50

    1

    100

    Returns: 999999

  22. 100

    100

    100

    50

    49

    50

    2

    100

    Returns: 999973

  23. 100

    100

    100

    50

    50

    49

    3

    40

    Returns: 531316

  24. 100

    100

    100

    49

    49

    49

    10

    10

    Returns: 2402

  25. 100

    100

    100

    49

    49

    49

    20

    20

    Returns: 9602

  26. 100

    100

    100

    49

    50

    49

    9

    30

    Returns: 222068

  27. 100

    100

    100

    88

    36

    70

    0

    0

    Returns: 1

  28. 100

    100

    100

    34

    7

    49

    1

    1

    Returns: 26

  29. 100

    100

    100

    75

    91

    43

    0

    1

    Returns: 27

  30. 1

    1

    1

    0

    0

    0

    0

    0

    Returns: 1

  31. 1

    1

    1

    0

    0

    0

    0

    100

    Returns: 1

  32. 19

    20

    20

    16

    5

    11

    10

    11

    Returns: 1520

  33. 18

    15

    10

    2

    8

    1

    8

    10

    Returns: 690

  34. 10

    12

    19

    8

    5

    6

    5

    17

    Returns: 1794

  35. 11

    15

    16

    7

    8

    5

    9

    12

    Returns: 330

  36. 13

    15

    13

    2

    14

    6

    9

    15

    Returns: 1248

  37. 11

    20

    10

    6

    4

    8

    8

    10

    Returns: 462

  38. 49

    52

    40

    12

    11

    2

    22

    49

    Returns: 74992

  39. 54

    60

    56

    40

    42

    35

    24

    26

    Returns: 15972

  40. 49

    59

    53

    12

    23

    13

    11

    22

    Returns: 47439

  41. 59

    59

    58

    32

    43

    17

    30

    32

    Returns: 23160

  42. 49

    55

    51

    38

    45

    19

    39

    57

    Returns: 17493

  43. 57

    42

    51

    37

    23

    31

    27

    39

    Returns: 33222

  44. 99

    96

    88

    43

    12

    74

    69

    76

    Returns: 117810

  45. 83

    93

    81

    48

    78

    61

    38

    51

    Returns: 175530

  46. 81

    100

    91

    51

    26

    26

    27

    70

    Returns: 566110

  47. 87

    87

    96

    39

    57

    87

    40

    81

    Returns: 419562

  48. 90

    80

    85

    43

    5

    78

    42

    95

    Returns: 424752

  49. 89

    93

    87

    22

    33

    0

    35

    70

    Returns: 452007

  50. 13

    95

    64

    9

    0

    36

    3

    97

    Returns: 78965

  51. 59

    40

    49

    49

    8

    37

    36

    91

    Returns: 31040

  52. 80

    82

    80

    41

    53

    50

    19

    45

    Returns: 393347

  53. 75

    51

    70

    69

    32

    21

    23

    59

    Returns: 181538

  54. 93

    44

    16

    26

    23

    14

    20

    67

    Returns: 41136

  55. 89

    60

    26

    7

    25

    2

    5

    82

    Returns: 138273

  56. 17

    22

    98

    5

    11

    5

    9

    45

    Returns: 15742

  57. 35

    55

    37

    34

    14

    31

    0

    74

    Returns: 71225

  58. 80

    93

    78

    78

    79

    9

    7

    94

    Returns: 578968

  59. 34

    58

    1

    2

    55

    0

    55

    67

    Returns: 34

  60. 96

    5

    3

    26

    2

    0

    5

    8

    Returns: 120

  61. 91

    5

    3

    13

    1

    0

    5

    5

    Returns: 30

  62. 93

    5

    2

    76

    4

    0

    9

    27

    Returns: 270

  63. 93

    4

    2

    5

    3

    1

    3

    24

    Returns: 210

  64. 5

    88

    4

    3

    61

    2

    3

    6

    Returns: 180

  65. 4

    91

    4

    2

    4

    3

    4

    9

    Returns: 112

  66. 5

    4

    93

    0

    2

    43

    4

    5

    Returns: 108

  67. 3

    5

    97

    0

    1

    69

    0

    1

    Returns: 18

  68. 96

    89

    2

    46

    39

    1

    3

    4

    Returns: 112

  69. 84

    91

    4

    8

    17

    2

    3

    9

    Returns: 1268

  70. 92

    4

    80

    42

    3

    65

    5

    18

    Returns: 4560

  71. 83

    4

    98

    74

    2

    34

    3

    10

    Returns: 1496

  72. 3

    96

    86

    1

    74

    34

    0

    8

    Returns: 867

  73. 4

    90

    95

    3

    11

    8

    1

    9

    Returns: 1367

  74. 100

    1

    1

    99

    0

    0

    3

    7

    Returns: 5

  75. 100

    1

    1

    99

    0

    0

    34

    69

    Returns: 36

  76. 1

    100

    1

    0

    66

    0

    2

    22

    Returns: 42

  77. 1

    100

    1

    0

    66

    0

    4

    44

    Returns: 71

  78. 1

    100

    1

    0

    5

    0

    4

    6

    Returns: 5

  79. 1

    100

    1

    0

    5

    0

    5

    6

    Returns: 3

  80. 1

    100

    1

    0

    5

    0

    6

    6

    Returns: 1

  81. 1

    100

    1

    0

    5

    0

    7

    7

    Returns: 1

  82. 1

    1

    100

    0

    0

    0

    18

    23

    Returns: 6

  83. 1

    1

    100

    0

    0

    26

    20

    24

    Returns: 10

  84. 99

    100

    1

    13

    31

    0

    20

    60

    Returns: 5521

  85. 99

    100

    1

    13

    31

    0

    1

    6

    Returns: 168

  86. 100

    99

    1

    1

    94

    0

    3

    90

    Returns: 8720

  87. 99

    1

    98

    25

    0

    96

    0

    3

    Returns: 35

  88. 99

    1

    98

    25

    0

    96

    0

    4

    Returns: 54

  89. 99

    1

    98

    25

    0

    96

    0

    5

    Returns: 77

  90. 97

    1

    100

    0

    0

    0

    8

    13

    Returns: 132

  91. 1

    100

    99

    0

    26

    23

    1

    3

    Returns: 48

  92. 1

    100

    99

    0

    26

    23

    31

    33

    Returns: 342

  93. 1

    97

    98

    0

    96

    96

    95

    100

    Returns: 386

  94. 100

    100

    100

    8

    38

    37

    6

    10

    Returns: 7048

  95. 100

    100

    100

    8

    37

    38

    6

    10

    Returns: 7048

  96. 100

    100

    100

    8

    38

    38

    6

    10

    Returns: 7048

  97. 100

    100

    100

    8

    37

    37

    6

    12

    Returns: 11794

  98. 2

    2

    2

    0

    1

    1

    1

    1

    Returns: 7

  99. 2

    2

    2

    1

    0

    1

    1

    1

    Returns: 7

  100. 2

    2

    2

    1

    1

    0

    1

    1

    Returns: 7

  101. 2

    2

    2

    0

    1

    1

    0

    1

    Returns: 8

  102. 2

    2

    2

    1

    0

    1

    0

    1

    Returns: 8

  103. 2

    2

    2

    1

    1

    0

    0

    1

    Returns: 8

  104. 6

    6

    6

    3

    3

    3

    1

    2

    Returns: 124

  105. 100

    100

    100

    50

    50

    50

    3

    50

    Returns: 999875

  106. 100

    100

    100

    10

    10

    10

    0

    0

    Returns: 1

  107. 1

    1

    1

    0

    0

    0

    0

    1

    Returns: 1

  108. 5

    1

    1

    2

    0

    0

    1

    1

    Returns: 2

  109. 100

    100

    100

    95

    95

    95

    10

    100

    Returns: 997256

  110. 50

    43

    25

    3

    7

    5

    2

    7

    Returns: 2118

  111. 100

    99

    98

    1

    97

    55

    0

    33

    Returns: 82075

  112. 10

    10

    10

    5

    5

    5

    1

    3

    Returns: 342

  113. 100

    100

    100

    5

    5

    5

    1

    2

    Returns: 124


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: