Divisors

3

10 votes
Open, Algorithms, Approved, Easy, Mathamatics
Problem

Given three numbers N, A and B. Find how integers in range from 1 to N are divisible by A or B.

Input:
Input contains three integers N, A and B separated by space.

Output:
Print total numbers of integers in range from 1 to N are divisible by A or B.

Constraints:

Test Files 1 to 5:
1<=N<=100
1<=A<=100
1<=B<=100

Test Files 6 to 10
1<=N<=1012
1<=A<=105
1<=B<=105

Sample Input
25 3 5

Sample Output
12
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

N= 25 , A = 3 and B= 5

12 numbers which are divisible by 3 or 5 in range 1 to N are given below:
3, 5, 6, 9, 10, 12, 15, 18, 20, 21, 24, 25

Editor Image

?