BdMO National 2021 Higher Secondary Problem 7

Discussion on Bangladesh Mathematical Olympiad (BdMO) National

Did you solve it on the contest?

Yes
0
No votes
No
3
43%
No, but I solved it afterwards
4
57%
 
Total votes: 7

User avatar
Anindya Biswas
Posts:264
Joined:Fri Oct 02, 2020 8:51 pm
Location:Magura, Bangladesh
Contact:
BdMO National 2021 Higher Secondary Problem 7

Unread post by Anindya Biswas » Sat Apr 10, 2021 4:54 pm

একটা বাইনারি স্ট্রিং হলো এমন একটা শব্দ যার মধ্যে খালি \(0\) আর \(1\) আছে। কোনো বাইনারি স্ট্রিংয়ে একটা \(1\)-রান হলো এমন একটা সাবস্ট্রিং যেটাতে খালি \(1\) আছে এবং যেটাকে আর ডানে বা বামে বড় করা যায় না। কোনো একটা ধনাত্মক পূর্ণসংখ্যা \(n\)-এর জন্য \(B(n)\) হলো \(n\)-কে বাইনারিতে লিখলে এতে যতগুলো \(1\)-রান থাকে, সেই সংখ্যাটা। উদাহরণস্বরূপ, \(B(107)=3\) কারণ \(107\)-কে বাইনারিতে লিখলে হয় \(1101011\) এবং এটাতে ঠিক তিনটা \(1\)-রান আছে। নিচের রাশিটার মান কত?
\[B(1)+B(2)+B(3)+\cdots+B(255)\]

A binary string is a word containing only $0$s and $1$s. In a binary string, a $\text{1-run}$ is a non-extendable substring containing only $1$s. Given a positive number $n$, Let $B(n)$ be the number of $\text{1-runs}$ in the binary representation of $n$. For example, $B(107)=3$ since $107$ in binary is $1101011$ which has exactly three $\text{1-runs}$. What is the following expression equal to? \[B(1)+B(2)+B(3)+\dots+B(511)\]
Last edited by Anindya Biswas on Sun Apr 11, 2021 10:32 am, edited 1 time in total.
"If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is."
John von Neumann

User avatar
Anindya Biswas
Posts:264
Joined:Fri Oct 02, 2020 8:51 pm
Location:Magura, Bangladesh
Contact:

Re: Solution :

Unread post by Anindya Biswas » Sat Apr 10, 2021 8:25 pm

First thing you will notice is that $511=2^9-1$, which is the largest number with $9$ bit long binary string. For this particular problem, we will consider every integer number from $0$ to $2^9-1$ as a $9$-bit long binary string. For example, $2_{10}=10_2=00000010_2$, which is now a $9$ bit long binary string.
Notice that considering every non negative integer less that or equal to $511$ as a $9$ bit long binary string neither change the number of $\text{1-runs}$ nor their lengths.
Let's now define similarly the $\text{0-runs}$. In a binary string of $9$ bits length, a $\text{0-run}$ is a non-extendable substring that contains only $0$s. Let $C(n)$ be the number of $\text{0-runs}$ in the binary representation of $n$ where $n$ is a nonnegative integer, $n\leq2^9-1$, and the binary representation of $n$ is considered to have a length of $9$ bits.

Let's consider another topic, the $\text{0-runs}$ and $\text{1-runs}$ partition the binary representation in $B(n)+C(n)$ parts. As always, here's an example : $111$-$00$-$11$-$00$ is partitioned into $4$ parts separated by hyphens where each part is either a $\text{0-run}$ or a $\text{1-run}$. Let's call this parts "$\text{island}$".

We also observe that a $9$-bit long binary string has at least one $\text{island}$ and no more than $9\text{ islands}$.
$\therefore 1\leq B(n)+C(n)\leq9$.

There's a well known theorem in combinatorics named Stars and Bars theorem that says a positive number $n$ can be written as a sum of $k$ positive integers in $n-1\choose k-1$ ways.
That means the $9$-bit long binary string can be partitioned into $k$ islands in $8\choose k-1$ different ways.
Here, each number corresponds to a partition. If $n$ corresponds to a partition $P$, then $2^9-1-n$ also corresponds to that partition $P$. Since the binary string associated with $2^9-1-n$ can be found just by flipping every bit of binary representation of $n$. Every number other than $n$ and $2^9-1-n$ corresponds to different partitions.
Summarizing, the equation $B(n)+C(n)=k$ has $2\cdot{8\choose k-1}$ solution. That means there are $2\cdot{8\choose k-1}$ nonnegative integers $n, n\leq2^9-1$ such that $B(n)+C(n)=k$.
Therefore we get : \[\sum_{i=0}^{2^9-1} B(i)+C(i)=\sum_{k=1}^{9} 2\cdot{8\choose k-1}\cdot k\]
We already mentioned,
We can get the binary representation of $2^9-1-n$ by flipping every bit of binary representation of $n$.
That means, $B(n)=C(2^9-1-n)$
So, \[\sum_{i=0}^{2^9-1} B(i)=\sum_{i=0}^{2^9-1} C(i)\]
\[\therefore \boxed{\sum_{i=0}^{2^9-1} B(i)=\sum_{k=1}^{9} {8\choose k-1}\cdot k=1280}\]
There might be mistakes, if you spot any, feel free to acknowledge me.
"If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is."
John von Neumann

User avatar
Mahiir
Posts:9
Joined:Sun Dec 13, 2020 1:50 pm
Contact:

Re: BdMO National 2021 Higher Secondary Problem 7

Unread post by Mahiir » Tue May 11, 2021 2:43 pm

Anindya Biswas wrote:
Sat Apr 10, 2021 4:54 pm
একটা বাইনারি স্ট্রিং হলো এমন একটা শব্দ যার মধ্যে খালি \(0\) আর \(1\) আছে। কোনো বাইনারি স্ট্রিংয়ে একটা \(1\)-রান হলো এমন একটা সাবস্ট্রিং যেটাতে খালি \(1\) আছে এবং যেটাকে আর ডানে বা বামে বড় করা যায় না। কোনো একটা ধনাত্মক পূর্ণসংখ্যা \(n\)-এর জন্য \(B(n)\) হলো \(n\)-কে বাইনারিতে লিখলে এতে যতগুলো \(1\)-রান থাকে, সেই সংখ্যাটা। উদাহরণস্বরূপ, \(B(107)=3\) কারণ \(107\)-কে বাইনারিতে লিখলে হয় \(1101011\) এবং এটাতে ঠিক তিনটা \(1\)-রান আছে। নিচের রাশিটার মান কত?
\[B(1)+B(2)+B(3)+\cdots+B(255)\]

A binary string is a word containing only $0$s and $1$s. In a binary string, a $\text{1-run}$ is a non-extendable substring containing only $1$s. Given a positive number $n$, Let $B(n)$ be the number of $\text{1-runs}$ in the binary representation of $n$. For example, $B(107)=3$ since $107$ in binary is $1101011$ which has exactly three $\text{1-runs}$. What is the following expression equal to? \[B(1)+B(2)+B(3)+\dots+B(511)\]
$\textbf{Solution}:$

$B(n)\in \{1,2,3,4,5\}$

Let's count for each value \(B(n)\) how many numbers are there.

$\Gamma{(k)}$= The number of elements in the set $P$ such that $B(x)=k$ for all $x\in{P}$

Case-1: \(B(n)\)=1

$\Gamma{(1)}=45$
By Combinatorial Distribution Modeling one can find
$\Gamma{(1)}= 1+2+3+4+5+6+7+8+9 = 45$

Case-2: \(B(n)\)=2

$\Gamma{(2)}=210 $
By Combinatorial Distribution Modeling one can find
$\Gamma{(2)}=\dbinom{7}{6}+\dbinom{6}{5}\times{\dbinom{3}{1}}+\dbinom{5}{4}\times{\dbinom{4}{2}}+\dbinom{4}{3}\times{\dbinom{5}{3}}+\dbinom{3}{2}\times{\dbinom{6}{4}}+\dbinom{2}{1}\times{\dbinom{7}{5}}+\dbinom{8}{6} =210$

We have done it considering, two types of box $\triangle$ for distributing $0$'s and $\square$ for distributing $1$'s

Actually $\triangle$ is representing a run (a substring containing only $0$ or $1$ ) of $0$'s and $\square$ is representing a run of $1$'s

${\Large\triangle} {\huge\square} {\huge\triangle} {\huge\square} {\Large\triangle} $
Now put one $1$'s in each of the $\square$ boxes and put one $0$'s in the middle $\triangle$ box .
Distribute other 6 bits considering their different identities ( 0 or 1 ) in the other boxes respectively.
No need to worry there is remain a bijection relationship with the numbers from $1$ to $511$ in their binary form

Case-3: \(B(n)\)=3

$ \Gamma{(3)}=210 $
Similarly
${\Large\triangle} {\huge\square} {\huge\triangle} {\huge\square} {\huge\triangle} {\huge\square} {\Large\triangle} $
Now put one $1$'s in each of the $\square$ boxes and put one $0$'s in the middle two $\triangle$ boxes .
then distribute other 4 bits considering their different identities ( 0 or 1 ) in the other boxes respectively.
Case-4: \(B(n)\)=4

$\Gamma{(4)}=45$


Case-5: \(B(n)\)=5

$ \Gamma{(5)}=1 $

So our Answer is $\sum_{x\in{1}}^{5} x\times{\Gamma{(x)}} = 45\times{1}+210\times{2}+210\times{3}+45\times{4}+1\times{5} = 1280$

Post Reply