TopCoder problem "Divisibility" used in TCHS SRM 16 (Division I Level Three)



Problem Statement

    Given a int[] a, return the number of integers between L and R, inclusive, that are divisible by at least one of the elements in a.
 

Definition

    
Class:Divisibility
Method:numDivisible
Parameters:int, int, int[]
Returns:int
Method signature:int numDivisible(int L, int R, int[] a)
(be sure your method is public)
    
 

Constraints

-L will be between 1 and 1000,000,000, inclusive.
-R will be between L and 1000,000,000, inclusive.
-a will contain between 1 and 18 elements, inclusive.
-Each element of a will be between 1 and 1000,000,000, inclusive.
 

Examples

0)
    
293
784
{1}
Returns: 492
1)
    
255
734
{2}
Returns: 240
2)
    
579000
987654
{1,2}
Returns: 408655
3)
    
1
1000000000
{2,3}
Returns: 666666667

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10068&pm=6658

Writer:

VitalyGoldstein

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Math