Long number

2020 VietMX 0

Consider the following grammar: <expression> ::= <term> | <expression> ‘+’ <term> <term> ::= <number> | <number> ‘-‘ <number> | <number> ‘(‘ <expression> ‘)’ <number> ::= […]

Yuhao and a Parenthesis

2020 VietMX 0

One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences. A bracket sequence is any non-empty sequence of […]

Makoto and a Blackboard

2020 VietMX 0

Makoto has a big blackboard with a positive integer $n$ written on it. He will perform the following action exactly $k$ times: Suppose the number […]

Alex and a TV Show

2020 VietMX 0

Alex decided to try his luck in TV shows. He once went to the quiz named “What’s That Word?!“. After perfectly answering the questions “How […]

Egor and an RPG game

2020 VietMX 0

One Saturday afternoon Egor was playing his favorite RPG game. While discovering new lands and territories, he came across the following sign: Egor is a […]

Mateusz and an Infinite Sequence

2020 VietMX 0

A Thue-Morse-Radecki-Mateusz sequence (Thorse-Radewoosh sequence in short) is an infinite sequence constructed from a finite sequence $\mathrm{gen}$ of length $d$ and an integer $m$, obtained in the […]

Flowers and Chocolate

2020 VietMX 0

It’s Piegirl’s birthday soon, and Pieguy has decided to buy her a bouquet of flowers and a basket of chocolates. The flower shop has F different types […]

The Child and Binary Tree

2020 VietMX 0

Our child likes computer science very much, especially he likes binary trees. Consider the sequence of n distinct positive integers: c 1, c 2, …, c n. The child calls a vertex-weighted rooted binary […]

Epic Convolution

2020 VietMX 0

You are given two arrays $a_0, a_1, \ldots, a_{n – 1}$ and $b_0, b_1, \ldots, b_{m-1}$, and an integer $c$. Compute the following sum: $$\sum_{i=0}^{n-1} […]

Parity

2020 VietMX 1

You are given an integer $n$ ($n \ge 0$) represented with $k$ digits in base (radix) $b$. So, $$n = a_1 \cdot b^{k-1} + a_2 […]

Tape

2020 VietMX 0

You have a long stick, consisting of $m$ segments enumerated from $1$ to $m$. Each segment is $1$ centimeter long. Sadly, some segments are broken […]