TopCoder problem "ProductTriplet" used in Member SRM 458 (Division II Level Three)



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

0)
    
2
2
3
3
6
6
Returns: 1
2 * 3 = 6.
1)
    
2
2
3
3
7
7
Returns: 0
2 * 3 is not 7.
2)
    
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.
3)
    
1
458
1
458
1
458
Returns: 2877
4)
    
8176
184561
1348
43168
45814517
957843164
Returns: 2365846085

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10698

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=14180&pm=10698

Writer:

rng_58

Testers:

Rustyoldman , timmac , ivan_metelsky , mohamedafattah , it4.kp

Problem categories:

Brute Force, Math