Let S = { 1 , − 1 } . A sequence ( a 1 , a 2 , ⋯ , a n ) is called balanced if the following conditions hold:
Find the number of balanced sequences of length 2 0 1 6 (the number of balanced sequences with n = 2 0 1 6 ). Enter the last three digits of the answer.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
I think this s is not quite right. There is, for example, the option that one starts with +1, then has alternating -1, +1, -1, ... and ends on +1, +1 (this leaves the series between 0 and 2, is thus allowed. There are several of these.
Here is my alternative: 1. there are three "corridors" for S_i, (i) between 0 and 2, (ii) between -1 and 1, (iii) between -2 and 0. Each of these corridors has (by the same argument as Sreejato's, 2^1008 possibilities (this is obvious for the middle corridor, the other two have 1007 alternating pairs + one "dangling +1 or -1).
Thus, the total should be 3 * 2^1008, which evaluates to 248 modulo 1000.
Log in to reply
The sequence you mentioned corresponds to the set { n − 1 } of repetitive indices.
I'm not sure what you mean by "corridors"- could you explain?
Log in to reply
By "corridors" I mean the following: the max S i and min S i cannot be more than 2 apart. That means that of the total of five options for any S_i, -2, -1, 0, 1, 2, only three consecutive ones can be used. Thus, the total series has to move either between 0 and 2, -1 and 1, or -2 and 0.
Log in to reply
@Susanne Yelin – I solved the problem in a similar way, but 3 * 2^1008 mod 1000 should evaluate to 768. Also, there are two double counted sequences: one where the max and min S_i are 1 and 0, and a sequence where they are 0 and -1. Because the max and min partial sums are only one apart, they fall under two different corridors. So we subtract 2 from our answer to get 766.
Log in to reply
@Dylan Young – I did the mod calculation by hand, so yes, there might be a mistake.
And also yes to the two double-counted sequences. I also figured this last night.
So, yes, I agree, it should be (3*2^1008 - 2) mod 1000.
Problem Loading...
Note Loading...
Set Loading...
The condition is essentially saying that the absolute difference of the numbers of 1's and -1's in any contiguous subsequence doesn't exceed 2.
Call an index i ( 1 ≤ i < n ) repetitive if a i = a i + 1 . Note that if we fix the set of repetitive indices, there are exactly two possibilities for the sequence (one starts with 1, the other starts with -1, and the remaining positions are filled with alternating 1's and -1's).
Now, note that the parity of all repetitive indices are same. To see why (let's say A=1 and B=-1), suppose we have two consecutive A's. Then, there must exist a pair of two consecutive B's between the next pair of consecutive A's, otherwise the substring is like ...AABABABAA..., which violates the condition (number of A's - number of B's > 2). Thus, the next repetitive index must be a B, and all B's are placed at an even distance from the first repetitive index.
If the parity of all repetitive indices are odd, we get 2 ⌈ ( n − 1 ) / 2 ⌉ possibilities (just select a subset consisting entirely of odd numbers among the first n − 1 natural numbers). Similarly, if the parity of all repetitive indices are even, we get 2 ⌊ ( n − 1 ) / 2 ⌋ possibilities. Overall, the answer is 2 ( 2 ⌈ ( n − 1 ) / 2 ⌉ + 2 ⌊ ( n − 1 ) / 2 ⌋ − 1 ) (-1 because we double count the empty set for both cases).
In this case, our answer is 2 ( 2 1 0 0 7 + 2 1 0 0 8 − 1 ), which evaluates to 7 7 6 modulo 1000.