FizzBuzzTurbo
TCO14 Round 1C · 2014-03-26 · by misof
Problem Statement
Fizz Buzz is a simple game used to teach kids about divisibility. The goal of the game is to say positive integers in increasing order, with a twist: You don't say the numbers divisible by 3 and 5. Instead, whenever a number was divisible by 3 you say "fizz" and for a number divisible by 5 you say "buzz". (Thus, if a number was divisible by 15, you say "fizzbuzz".)
Here is how the game starts: 1, 2, fizz, 4, buzz, fizz, 7, 8, fizz, buzz, 11, fizz, 13, 14, fizzbuzz, 16, 17, fizz, 19, buzz, fizz, 22, 23, fizz, buzz, 26, fizz, 28, 29, fizzbuzz, 31, 32, fizz, 34, buzz, fizz, ...
Fizz Buzz has also become a traditional programming interview question. However, in this problem we have a more tricky assignment for you.
You are given
Notes
- The return value can be quite large. Make sure to use the appropriate data type.
Constraints
- A will be between 1 and 10^18, inclusive.
- B will be between A and 10^18, inclusive.
1
4
Returns: {1, 0, 0 }
This is the sequence "1, 2, fizz, 4".
2
6
Returns: {2, 1, 0 }
This is the sequence "2, fizz, 4, buzz, fizz".
150
165
Returns: {4, 2, 2 }
This sequence begins and ends with a "fizzbuzz". There are some "fizz"es and some "buzz"es inbetween.
474747
747474
Returns: {72728, 36363, 18182 }
1
1
Returns: {0, 0, 0 }
Submissions are judged against all 137 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FizzBuzzTurbo with a public method vector<long long> counts(long long A, long long B) · 137 test cases · 2 s / 256 MB per case