Statistics

Problem Statement for "ProductTriplet"

Problem Statement

You are given six integers, minx, maxx, miny, maxy, minz and maxz. Return the number of triplets of integers (x,y,z) that satisfy the following three conditions:
  • x is between minx and maxx, inclusive.
  • y is between miny and maxy, inclusive.
  • z is between minz and maxz, inclusive.
  • x * y = z

Definition

Class:
ProductTriplet
Method:
countTriplets
Parameters:
int, int, int, int, int, int
Returns:
long
Method signature:
long countTriplets(int minx, int maxx, int miny, int maxy, int minz, int maxz)
(be sure your method is public)

Constraints

  • maxx will be between 1 and 1,000,000,000, inclusive.
  • maxy will be between 1 and 1,000,000,000, inclusive.
  • maxz will be between 1 and 1,000,000,000, inclusive.
  • minx will be between 1 and maxx, inclusive.
  • miny will be between 1 and maxy, inclusive.
  • minz will be between 1 and maxz, inclusive.

Examples

  1. 2

    2

    3

    3

    6

    6

    Returns: 1

    2 * 3 = 6.

  2. 2

    2

    3

    3

    7

    7

    Returns: 0

    2 * 3 is not 7.

  3. 6

    8

    4

    5

    27

    35

    Returns: 4

    (x,y,z) = (6,5,30), (7,4,28), (7,5,35) and (8,4,32) satisfy all conditions.

  4. 1

    458

    1

    458

    1

    458

    Returns: 2877

  5. 8176

    184561

    1348

    43168

    45814517

    957843164

    Returns: 2365846085

  6. 374483

    1918190

    4

    11

    7

    67

    Returns: 0

  7. 3

    3

    6171537

    9011084

    6

    182546394

    Returns: 2839548

  8. 1698590

    2961279

    5

    16

    8884401

    1000000000

    Returns: 15073989

  9. 80

    499

    42

    883488165

    1

    1

    Returns: 0

  10. 5

    14

    1313

    400427945

    672896

    659998485

    Returns: 770243270

  11. 1

    4

    1826

    142750432

    8

    1000000000

    Returns: 570994428

  12. 3444

    3901

    45

    1000000000

    24643

    28237

    Returns: 0

  13. 110781

    253423

    270308722

    1000000000

    1

    15934105

    Returns: 0

  14. 15

    162

    311316

    1000000000

    4444

    1000000000

    Returns: 2370258227

  15. 1

    248402491

    394871

    1644299

    11

    49

    Returns: 0

  16. 20

    669566825

    39

    41

    2

    35222246

    Returns: 2642712

  17. 6

    807426510

    3344

    4765

    1

    1000000000

    Returns: 354376489

  18. 7

    86979691

    164

    339228196

    2

    3

    Returns: 0

  19. 604

    287487107

    16558

    589759002

    1

    808284659

    Returns: 2752570292

  20. 6498

    14983332

    1

    761170565

    512

    1000000000

    Returns: 7735785276

  21. 3269

    5748439

    83150301

    1000000000

    9493

    28203

    Returns: 0

  22. 1905

    145324180

    314092452

    1000000000

    609

    6364914

    Returns: 0

  23. 2

    653962274

    865834128

    1000000000

    319390

    1000000000

    Returns: 0

  24. 1596982

    1000000000

    208

    241

    71

    79

    Returns: 0

  25. 3883818

    1000000000

    7909

    15165

    5056

    212677189

    Returns: 0

  26. 1138

    1000000000

    674290

    1151090

    16

    1000000000

    Returns: 32267110

  27. 736

    1000000000

    31

    2583104

    1

    1

    Returns: 0

  28. 3

    1000000000

    10

    9984371

    149

    442727411

    Returns: 6113349956

  29. 1

    1000000000

    11429

    117157997

    7713

    1000000000

    Returns: 9176028858

  30. 21

    1000000000

    49312

    1000000000

    96

    147

    Returns: 0

  31. 1282

    1000000000

    19

    1000000000

    2263

    68043416

    Returns: 473740459

  32. 88570

    1000000000

    18108208

    1000000000

    138149

    1000000000

    Returns: 0

  33. 1

    1000000000

    1

    1000000000

    1

    1000000000

    Returns: 20877697634

  34. 23

    992994009

    343

    992994009

    54

    992994009

    Returns: 10690944075

  35. 1

    999999999

    1

    999999999

    1

    999999999

    Returns: 20877697534

  36. 3

    999999999

    3

    999999999

    3

    999999999

    Returns: 17877697542

  37. 1

    999999

    2

    999999

    3

    999999

    Returns: 12969985

  38. 1

    100000000

    1

    100000000

    1

    100000000

    Returns: 1857511568

  39. 3

    1000000000

    10

    1000000000

    31

    999999999

    Returns: 16548729306

  40. 2

    1000000000

    1

    1000000000

    1

    1000000000

    Returns: 19877697634

  41. 1

    999999999

    1

    1000000000

    1

    1000000000

    Returns: 20877697633

  42. 123

    963915924

    3

    129475357

    6

    986429571

    Returns: 13789007380

  43. 1000000000

    1000000000

    1

    1000000000

    1

    1000000000

    Returns: 1

  44. 1

    1000000000

    1

    1

    1

    890000000

    Returns: 890000000


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: