Generalized FizzBuzz

면접 대비

시간 제한1초메모리 제한2048 MB

요약
정수 n, a, b가 주어질 때 1부터 n까지의 수 중 일반화된 FizzBuzz 규칙에 따라 Fizz, Buzz, FizzBuzz가 각각 몇 번 출력되는지 센다.
난이도

쉬움10점 중 3점

유형
수학, 정수론
정답자
아직 제출이 없습니다

문제

FizzBuzz is a common coding interview problem. The problem is as follows:

Given a positive integer nn, for all integers ii from 1 to nn, inclusive:

  • If ii is divisible by both 33 and 55, print "FizzBuzz".
  • Otherwise, if ii is divisible by 33, print "Fizz".
  • Otherwise, if ii is divisible by 55, print "Buzz".
  • Otherwise, print ii.

We are interested in a generalized version of FizzBuzz:

Given three positive integers nn, aa, and bb, for all integers ii from 1 to nn, inclusive:

  • If ii is divisible by both aa and bb, print "FizzBuzz".
  • Otherwise, if ii is divisible by aa, print "Fizz".
  • Otherwise, if ii is divisible by bb, print "Buzz".
  • Otherwise, print ii.

Given nn, aa and bb, how many times are "Fizz", "Buzz", and "FizzBuzz" printed for a correct implementation?

입력

The first and only line of input contains three positive integers nn, aa and bb (1≤n,a,b≤106.)(1 \le n, a, b \le 10^6.)

출력

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.

예제2

  1. 예제 1

    입력
    17 3 5
    
    예상 출력
    4 2 1
    
  2. 예제 2

    입력
    10 3 3
    
    예상 출력
    0 0 3