forked from keshavnandan/Topcoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFizzBuzzTurbo.txt
75 lines (44 loc) · 1.69 KB
/
FizzBuzzTurbo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 long longs A and B.
Consider the part of the game that corresponds to integers from A to B, inclusive.
During this part of the game, you will say "fizz" X times, "buzz" Y times, and "fizzbuzz" Z times.
Return a vector<long long> with three elements: {X,Y,Z}.
DEFINITION
Class:FizzBuzzTurbo
Method:counts
Parameters:long long, long long
Returns:vector<long long>
Method signature:vector<long long> counts(long long A, long long B)
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.
EXAMPLES
0)
1
4
Returns: {1, 0, 0 }
This is the sequence "1, 2, fizz, 4".
1)
2
6
Returns: {2, 1, 0 }
This is the sequence "2, fizz, 4, buzz, fizz".
2)
150
165
Returns: {4, 2, 2 }
This sequence begins and ends with a "fizzbuzz". There are some "fizz"es and some "buzz"es inbetween.
3)
474747
747474
Returns: {72728, 36363, 18182 }