Problem C
Generalized FizzBuzz
FizzBuzz is a common coding interview problem. The problem is as follows:
Given a positive integer $n$, for all integers $i$ from 1 to $n$, inclusive:
-
If $i$ is divisible by both $3$ and $5$, print "FizzBuzz".
-
Otherwise, if $i$ is divisible by $3$, print "Fizz".
-
Otherwise, if $i$ is divisible by $5$, print "Buzz".
-
Otherwise, print $i$.
We are interested in a generalized version of FizzBuzz:
Given three positive integers $n$, $a$, and $b$, for all integers $i$ from 1 to $n$, inclusive:
-
If $i$ is divisible by both $a$ and $b$, print "FizzBuzz".
-
Otherwise, if $i$ is divisible by $a$, print "Fizz".
-
Otherwise, if $i$ is divisible by $b$, print "Buzz".
-
Otherwise, print $i$.
Given $n$, $a$ and $b$, how many times are "Fizz", "Buzz", and "FizzBuzz" printed for a correct implementation?
Input
The first and only line of input contains three positive integers $n$, $a$ and $b$ $(1 \le n, a, b \le 10^6.)$
Output
Output three integers: the number of times "Fizz" is printed, the number of times "Buzz" is printed, and the number of times "FizzBuzz" is printed.
Sample Input 1 | Sample Output 1 |
---|---|
17 3 5 |
4 2 1 |
Sample Input 2 | Sample Output 2 |
---|---|
10 3 3 |
0 0 3 |