Number Transformation

2020 VietMX 0

Little Petya likes positive integers a lot. Recently his mom has presented him a positive integer a. There’s only one thing Petya likes more than numbers: […]

Adding Digits

2020 VietMX 0

Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times. One operation of lengthening a […]

Ancient Prophesy

2020 VietMX 0

A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters […]

Balls and Boxes

2020 VietMX 0

Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right. […]

Dividing Kingdom

2020 VietMX 0

A country called Flatland is an infinite two-dimensional plane. Flatland has n cities, each of them is a point on the plane. Flatland is ruled by king […]

Black and White Tree

2020 VietMX 0

The board has got a painted tree graph, consisting of n nodes. Let us remind you that a non-directed graph is called a tree if it is […]

Flawed Flow

2020 VietMX 0

Emuskald considers himself a master of flow algorithms. Now he has completed his most ingenious program yet — it calculates the maximum flow in an […]

Magical Boxes

2020 VietMX 0

Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the […]

Greenhouse Effect

2020 VietMX 1

Emuskald is an avid horticulturist and owns the world’s longest greenhouse — it is effectively infinite in length. Over the years Emuskald has cultivated n plants in […]

Maximum Waterfall

2020 VietMX 0

Emuskald was hired to design an artificial waterfall according to the latest trends in landscape architecture. A modern artificial waterfall consists of multiple horizontal panels […]

Dima and Staircase

2020 VietMX 0

Dima’s got a staircase that consists of n stairs. The first stair is at height a 1, the second one is at a 2, the last one is at a n (1 ≤ a 1 ≤ a 2 ≤ … ≤ a n). Dima decided […]

Dima and Two Sequences

2020 VietMX 0

Little Dima has two sequences of points with integer coordinates: sequence (a 1, 1), (a 2, 2), …, (a n, n) and sequence (b 1, 1), (b 2, 2), …, (b n, n). Now Dima wants to count the number of distinct sequences of points of […]

Dima and Figure

2020 VietMX 0

Dima loves making pictures on a piece of squared paper. And yet more than that Dima loves the pictures that depict one of his favorite […]

Dima and Game

2020 VietMX 0

Dima and Anya love playing different games. Now Dima has imagined a new game that he wants to play with Anya. Dima writes n pairs of integers […]

Dima and Horses

2020 VietMX 0

Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric […]

Rectangle Puzzle

2020 VietMX 0

You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the […]

Maximum Xor Secondary

2020 VietMX 0

Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x 1, x 2, …, x k (k > 1) is such maximum element x j, that […]

Game on Tree

2020 VietMX 0

Momiji has got a rooted tree, consisting of n nodes. The tree nodes are numbered by integers from 1 to n. The root has number 1. Momiji decided to play a […]

Spyke Talks

2020 VietMX 0

Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during […]

Command Line Arguments

2020 VietMX 0

The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are […]