Tasks

Task 1

Perfect numbers

One day, while Jerry Cimrman was walking through a secluded bookstore in the heart of Europe, he came across an old, dusty book. The cover said: "Euclid: The Secrets of Perfect Numbers." Jerry, always curious, opened the book and began to read.

After a few pages, Cimrman thought: “Perfect numbers? That sounds like something I could use in my inventions!” He decided to study the book in depth. In the evening, when he returned to his modest apartment, he began to experiment. After several hours of hard thinking and counting, he managed to discover a new perfect number.

He was so excited that he decided to write a letter to Euclid. “Dear Mr. Euclid,” Cimrman began, “let me inform you that I have discovered a new perfect number. I am sure you would be proud of me!” He carefully sealed the letter and sent it to ancient Greece. A few weeks later he got a reply. It was a blank page with only one word: "Bravo!"

And so Jerry Cimrman became not only a famous inventor, but also a mathematician known for his discovery of the perfect number. Although no one ever saw his letter or the reply, Cimrman believed that his discovery had changed the world of mathematics forever.

And since then, whenever someone mentioned perfect numbers, Jerry just smiled and said, "That's my job!" Using perfect numbers, Cimrman also designed a complex astronomical clock for the capital city. But he had bad luck. Five minutes before he finished, another inventor completed a similar clock, so the capital city has an astronomical clock, which visitors to the city can still admire today, but it is not the one invented by Jerry Cimrman.

Task Description

“The task is to create a program that finds the first 5 perfect numbers in the range of 2 to 100,000,000. A perfect number is a number that is the sum of all its divisors except itself. (For example, 6 is a perfect number because 1 + 2 + 3 = 6. Similarly, 28 is a perfect number because 1 + 2 + 4 + 7 + 14 = 28.”)

Your task

Into the field with the answer enter:

  • the result – each perfect number should be on a new line
  • the country, which the story refers to
  • at the end paste the source code of your program.

Task 2

*
Due to faulty input file, this task does not have a solution and will not be evaluated and taken into consideration. We sincerely apologise.
*

Diamond amount/sum

Game story

Everyone is familiar with the chessboard problem, where the first square is filled with one, the second with two, the third with four, and so on, more and more grains of rice, doubling the previous number, going from cell to cell and from row to row. The question is how many grains of rice are there in total on the entire chessboard.

BUT! In this case, this is not exactly the question! Have something simpler and have something more complicated in this task!

The numbers in the cells only increase one by one, but the table can only have an odd number of elements and almost any size. The bonus is how you choose the cells that are important to you!

I wish you a good and successful puzzle!

Hint on the country of task provider

First Metro in Europe: our capital was the first city in continental Europe to have an underground metro system, which opened in 1896. It is still in operation today, and also known as the Millennium Underground Railway.

Task description

A square grid of size NxN (N is odd) is given. In the cells are integers from 1 to N2 have been written consecutively in ascending order.
The sum of the numbers lying along the segments connecting the midpoints of the sides of the square is called the diamond sum.
Calculate the remainder of the sum of diamonds of the specified size grid divided by 987654321.

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

 

In this case the sum will be (3+7+9+11+15+17+19+23) % 987654321 = 104 % 987654321 = 104

Input: N, where N is odd and (3 <= N <= 1018) conditions are met.

Output: The diamond sum of the grid is modulo 987654321.
 

Example input:
5

Example output:
104

Your task

Read input file with 3 inputs N. Into the field with the answer, enter:

  • the resulting values for each of the input N on a new line
  • the country, which the hint refers to
  • at the end paste the source code of your program.

 Click here to download the TASK 2 input file

Task 3

The Golden Claw

You have reached the ancient Temple of Delphi, hidden in the mountains of beautiful country. After exploring dark tunnels and fighting enemies, you find a large stone door. Behind this door is the treasure you are looking for, but it will not open. There is no handle or lever to pull.

In front of you, on the ground, there is a number of pillars with `m` faces each. The pillars form a pyramid. On the door, there is also a pyramid structure sketch, with the same faces. After deciphering an elven description, you know what you have to do:

The pillars on ground must show the same face with the corresponding sketch on the door. However, each time you rotate a pillar, all the adjacent pillars below them rotates the same way also, cascading to the bottom of the pyramid.

 

Example:

Sketch on the door:

           1

           2 1

          3 1 0

 

Pillars on the ground:

            2

           1 1

          3 3 2

 

The pillar on the top has to be rotated 1 time counter clockwise (-1). Doing so will rotate all the other pillars resulting to:

            1

           0 0

          2 1 1

 

!! Notice, the 2nd pillar of the 3rd row moves 2 times.

Then, rotate the 1st pillar of the 2nd row 2 times clockwise (2).

            1

           2 0

          0 3 1

 

Problem input:

    The initial and target pyramid are given in the form of an array with length `n`. Also the number of faces `m` in each pillar are given

    For the above example, the configuration would be:

        faces = 4, initial = [2 1 1 3 3 2], target = [1 2 1 3 1 0],

 

0 < n < 10^8 (The pyramid will always have a full final row)

2 < m < 10

 

The solution should be an array of the same length as the input, giving how much the pillar should be rotated. (Only the manual rotation should be considered for the response, not the automatic cascading rotation).

    For the above example, the response would be:

        result = [-1 2 1 3 1 -2]

 

Clarification:

The input configuration for the exercise is given in the form of a text file with the following format:

4

2 1 1 3 3 2

1 2 1 3 1 0

 

Where the first row is the number of faces, the second row is the initial configuration, and the third row is the target configuration.

The output should be in the format:[-1, 2, 1, 3, 1, -2] 

Hint: Write your algorithm for the first two configurations first and then write the code that reads the input file and apply the algorithm to all configurations of the file.

 

Your task

Read input file and into the field with the answer, enter :

  • the resulting values for every case, each on a new line
  • the country, which the story refers to
  • at the end paste the source code of your program.

Click here to download the Task 3 Input File

Task 4 

Missing numbers

In a distant land, cradled by the towering Tatra Mountains and flowing rivers, where the brave robber Janosik robbed the rich people and gave to the poor, there was a village where numbers held a sacred place in the natural order. The villagers believed that numbers must exist in perfect sequence, and any gaps could disrupt the balance of their world. To prevent chaos, the wise elder would call upon the townsfolk to find the missing numbers and restore harmony.

This tradition reflected the deep mathematical heritage of their homeland—a place known for its medieval towns, stunning castles, and rich folklore. Today, you’ve been chosen to uphold this custom, just as generations before you have done in this central European land. Can you restore balance and honor the legacy of this nation?

Task Definition

Let's have an array of integers. The goal is to find missing elements and the minimum number of insertions needed to make all elements of the array consecutive integers.

Example:

Given the array arr = [4, 2, 1], the missing integer to make the array consecutive is 3. Therefore, the number of insertions needed is 1 and missing element is 3. Create a method, that counts how many integers are missing and return them.

Input Description

Input file contains n space-separated integers arr[i]. Check Input example for detailed overview.

Output Description

Output contains number n, which is minimum number of insertions needed to make array consecutive, following with comma and space separated missing elements in ascending order. Check output example for detailed explanation.

Input example

4 3 6 8

Output example

2: 5, 7

Your task

Read input file and into the field with the answer, enter :

  • the resulting values
  • the country, which the story refers to
  • at the end paste the source code of your program.

Click here to download the Task 4 Input File

Task 5

CCTV

Security in the Mercadona shopping center is ensured using a video surveillance system.

The security guard has a program open on his computer that displays video streams from several cameras. This program is structured as follows: a rectangular grid consisting of h rows and w columns is presented on the screen. Each cell can be empty, or an image from one of the cameras is displayed there. To control the location of images in the program, the security officer can use the left, right, up and down buttons.

The left button moves the image from each cell to the cell to the left of it. This moves the image from the leftmost cell in each row to the rightmost cell in that row.

The “right”, “up” and “down” buttons operate in a similar way. The right button moves the image from each cell to the cell to the right of it. The images in the rightmost cell in each row are moved to the leftmost cell in that row. The up button moves the image from each cell to the cell above it. Images from the topmost row are moved to the cells in the bottom row. The down button moves the image from each cell to the cell below it. Images from the bottom row are moved to cells in the top row.

Rows in the grid are numbered from top to bottom, columns are numbered from left to right. The cell at the intersection of row number r and column number c is designated as (r, c).

Below is a grid with 3 rows, 4 columns and three cells containing images, with coordinates (1, 1), (2, 4) and (3, 3). It also shows where these images will go when you click on each of the four buttons.

 

It is more convenient for the security guard that the cells on the monitor that contain the images from the cameras are located as compactly as possible. The compactness of images is the minimum area of ​​the grid subrectangle that contains all displayed images. Note that using the buttons you can change the compactness. For example, the left side of the figure below shows an image layout that has a compactness of 12. If you press the right button once and press the up button once, the image compactness becomes 4.

 

 

You are given a grid that contains k cells with images. Calculate the minimum compactness that can be achieved using the left, right, up and down buttons, as well as the minimum number of button presses required. In the example above correct answer is “2 moves, compactness is 4”.

Of course, you can solve the problem by completely searching through all the options, but you need to find a more optimal solution.

 

Input format

The first line contains three integers h, w, and k — the grid sizes and the number of cells with the image.

Each of the next k lines contains two integers ri and ci — the coordinates of the cell containing the image (1 ri h; 1 ci w). It is guaranteed that all k cells are different.

Output format

Print two integers — the minimum compactness of the image arrangement that can be achieved using buttons, and the minimum number of button presses required to achieve this compactness.

 

Example (from the story above):

Input:

Height; Width; Number of active cells

3; 4; 3

 

Coordinates

1; 4

3; 1

3; 4

 

Output (compactness; moves):

4; 2
 

Your task

Read input file with 2 cases and into the field with the answer, enter :

  • the resulting values for each case
  • the country, which description refers to
  • and the source code of your program.

Click here to download the Task 5 Input File

Answers

Task 1

Answer

6
28

496

8128

33550336

Czechia, the Czech republic

Points for

   

Correct answer

Country

Source Code

Round 1

1

1

1

Round 2

2

1

1

Round 3

3

1

1

Round 4

4

1

1

Round 5

5

1

1

 

Bonus points for

               

 

 

Quick and correct answer

 

Round 1

5

4

3

2

1

       

Round 2

                 

Round 3

7

6

5

4

3

2

1

   

Round 4

8

7

6

5

4

3

2

1

 

Round 5

9

8

7

6

5

4

3

2

1

Task 2

Answer

Due to faulty input file, this task does not have a solution and will not be evaluated and taken into consideration. We sincerely apologise.

Hungary
 

All the competitors receive full amount of points.

If you want try, here are correct input values (without evaluation and points):

137

31415

20241223

 

Correct results:

2552720

77391374

464692980

 

     

Points

Correct answer

Country

Source Code

Round 1

1

1

1

Round 2

2

1

1

Round 3

3

1

1

Round 4

4

1

1

Round 5

5

1

1

 

                 

 

Bonus points 

Quick and correct answer

 

Round 1

5

4

3

2

1

       

Round 2

                 

Round 3

7

6

5

4

3

2

1

   

Round 4

8

7

6

5

4

3

2

1

 

Round 5

9

8

7

6

5

4

3

2

1

Task 3

Answer

Greece

 

There are many correct answers.

Here is one of the possible correct answers, but because pillars can rotate to the right and to the left and both direction can move to the right position, the are many correct of combinations. Here is one of them:

[1, -1, 0, -2, 0, -1]

[1, -1, 2, 1, -1, 1]

[2, -2, 1]

[-1, -1, 0, 2, 0, 0]

[1, 4, 1]

[1, 0, 0]

[0, 0, 0]

[1, 0, -1, 1, 0, 0, 1, -1, -1, 0]

[3, 1, -3]

[0, 0, 1]

[0, 0, 1, -1, 0, -1]

[2, -2, 0, -3, 1, 0]

[3, -2, 5]

[1, -2, 0, 0, 0, 1, -1, -2, 0, 2]

[0, 0, 0, -1, 1, -1]

[0, -1, 1, -1, 0, -1, 1, 0, -1, 0]

[1, -3, -1, -1, 2, 1]

[1, 2, -1]

[1, 0, -3, -1, 0, -2, 0, -1, -2, -1]

[-1, 0, -1, 1, 0, -1]

[1, 3, -3, -1, -2, -1, 1, 3, -2, 1]

[-1, 0, 0]

[0, 2, -1]

[0, -1, -2, 0, 2, 0, -1, 2, -1, 0]

[3, 0, -1, 4, 2, 0]

[-3, -1, 3]

[1, 1, 2, 0, 0, 1, -1, 1, -1, -1]

[-1, 0, 1]

[-1, 0, 0]

[2, 2, 3]

[-3, -1, 0, 0, -1, 1]

[0, -1, 1, 0, 0, 1, -5, 4, 1, 0]

[-1, 1, 0, 1, 1, 0]

[0, 0, 0, 1, -1, -1, -1, 0, 1, 1]

[0, 0, -1]

[-1, 0, 1, 0, 0, 0, 0, 0, -1, 0]

[-1, 3, 1, 0, 1, 0, 1, 1, -1, 1]

[-2, 2, 0, 2, 1, 0, -2, 3, 1, 0]

[0, 2, -3, -3, 0, -1, 1, -1, 2, 0]

[1, 1, -1, 0, 0, 1, 0, 1, 0, -1]

[0, 0, 1, 0, 2, 3, 4, -2, -1, -2]

[-1, 1, 0, -2, -1, 0]

[-2, 0, -4, -2, 3, -1, -1, 1, -1, 0]

[-1, -1, 0, 1, 0, -1, 0, 0, 0, 0]

[-3, 0, 4]

[0, 0, 1]

[0, -1, 0, 0, 0, 0, 0, 0, 0, 1]

[0, -1, -1, 0, -1, 0]

[2, 2, -2, 1, 0, -1]

[-1, 0, -2, 4, 0, 3]

[-1, 0, 0]

[-2, -1, -2, -2, 1, 4]

[-3, 3, -2, 1, 2, -2, 0, 0, 0, -3]

[0, -1, 1, 0, 1, 1, 0, 1, 1, 0]

[0, -1, 2]

[-4, 0, -2]

[3, 4, -4, -3, 0, -2]

[1, -1, -3]

[1, 1, -1]

[-1, 0, 2]

[0, 0, 0]

[3, -2, 1]

[3, 2, -2, -1, 2, 0, -3, 1, 0, -2]

[0, 0, 2, 1, 0, 3]

[3, 0, -1, 3, -1, -2]

[-1, -5, 1, -3, 1, 3, 1, -2, 5, 0]

[4, 3, 1, 2, 2, -2, -3, -2, -1, -2]

[1, -1, 0, -2, -1, 0]

[0, 0, 2]

[-1, 1, 1, 0, -1, 1]

[0, -2, 4]

[1, 0, 1, 2, 1, -2]

[-1, -5, 1]

[-4, -4, 1]

[1, 0, 1, 0, -1, 0]

[0, -1, -3]

[1, 1, 2]

[-2, -2, -1, 5, 2, 2]

[1, 0, 0, 1, 1, 0, 1, 0, 0, 1]

[-2, 1, 1, -2, 1, 1, 0, 1, -1, 0]

[-1, -2, 3]

[1, 0, 0, -1, 0, 0]

[1, 2, -1]

[1, 0, -1, 0, -1, -1]

[1, 0, 1]

[1, 0, 0, 0, 0, -1, 1, 0, -1, 0]

[0, -3, -4]

[1, 2, 0, 0, 2, 2, 1, 0, -1, 1]

[-1, 0, 1]

[-1, -1, 2, 3, 0, 0]

[-1, 1, -1]

[0, 1, -1, 0, 0, -1]

[0, -1, 1, -1, -1, 0]

[2, -1, -2]

[0, -2, 0]

[-1, 0, 2, -2, 2, 1]

[0, -5, 0, -3, -1, -3, 3, 3, -3, -1]

[2, 1, 0, -1, -1, 1]

[1, -2, 2, 2, 1, -1]

[0, 0, -1, 0, 0, -2]

[2, 5, -6, 2, 0, 1, 0, 9, 8, 3, 0, -6, 1, -1, 2, 1, 4, 0, 3, -6, 0, -7, 3, 0, 4, 6, 1, -5, 4, -7, -1, -4, 3, -5, 1, -1, 0, 5, 4, -7, 4, -2, 9, 0, -5, 1, 4, -1, 5, 2, 7, 1, 3, -1, -3, -2, -2, -2, -1, 2, -2, -4, -1, -4, -2, 0, 0, -9, 1, -5, -2, -5, -6, 5, -1, -8, 0, -5, 4, -1, 1, -6, 2, 1, 2, 8, 2, -1, -2, -1, 2, 5, 2, 2, 2, 1, 7, 4, 0, -2, -2, 0, -4, -1, 1, 0, -2, 7, -4, -1, -1, 5, -6, 1, 5, 5, -3, -1, 5, 0, -2, 6, -7, 0, 5, -1, 4, -6, -3, -5, -1, 2, -5, -1, 2, 5, -1, -6, -6, -3, 2, -8, -6, -2, 4, 5, 0, 5, -1, 2, -1, -8, 0, -4, -8, -4, 1, 0, 4, 4, 4, 2, 3, 3, -4, -4, 1, 0, -6, 0, 1, -5, -3, 0, 4, 9, -2, 9, 1, -5, 1, -6, 1, 2, 4, -3, -8, -2, 1, 4, 0, 0, -1, -6, 4, 1, 2, 3, -5, 1, -2, 0, 0, -4, -2, -8, 0, 4, 5, -2]

We accepted also the answers, that input 2 faces and 10 faces is out of the conditions.

     

Points

Correct answer

Country

Source Code

Round 1

1

1

1

Round 2

2

1

1

Round 3

3

1

1

Round 4

4

1

1

Round 5

5

1

1

                 

 

Bonus points 

Quick and correct answer

 

Round 1

5

4

3

2

1

       

Round 2

                 

Round 3

7

6

5

4

3

2

1

   

Round 4

8

7

6

5

4

3

2

1

 

Round 5

9

8

7

6

5

4

3

2

1

 

Task 4

Answer

Slovakia (we accepted Poland as well)

 

202: 24, 42, 43, 54, 60, 70, 81, 89, 182, 193, 206, 281, 304, 305, 311, 344, 354, 380, 415, 445, 494, 500, 564, 651, 664, 665, 672, 691, 697, 722, 779, 783, 803, 818, 819, 827, 829, 838, 883, 918, 935, 949, 952, 957, 988, 992, 1008, 1024, 1041, 1145, 1147, 1151, 1166, 1167, 1172, 1177, 1184, 1190, 1191, 1194, 1198, 1225, 1228, 1256, 1274, 1277, 1294, 1320, 1328, 1337, 1344, 1351, 1353, 1396, 1397, 1417, 1439, 1457, 1464, 1495, 1507, 1542, 1559, 1578, 1585, 1615, 1647, 1662, 1673, 1719, 1737, 1772, 1793, 1817, 1830, 1837, 1870, 1932, 1962, 2028, 2039, 2047, 2049, 2052, 2055, 2057, 2087, 2121, 2127, 2151, 2266, 2268, 2278, 2282, 2289, 2298, 2308, 2317, 2348, 2350, 2368, 2404, 2413, 2415, 2468, 2484, 2514, 2522, 2523, 2527, 2530, 2532, 2542, 2596, 2617, 2635, 2639, 2648, 2651, 2682, 2713, 2738, 2743, 2748, 2780, 2784, 2792, 2806, 2868, 2895, 2903, 2917, 2941, 2961, 2979, 2990, 3042, 3097, 3114, 3130, 3147, 3173, 3179, 3198, 3209, 3218, 3271, 3282, 3310, 3363, 3371, 3386, 3423, 3462, 3485, 3493, 3495, 3525, 3557, 3566, 3571, 3572, 3578, 3587, 3598, 3636, 3639, 3645, 3646, 3659, 3667, 3688, 3693, 3703, 3709, 3727, 3803, 3817, 3850, 3861, 3907, 3980

 

     

Points

Correct answer

Country

Source Code

Round 1

1

1

1

Round 2

2

1

1

Round 3

3

1

1

Round 4

4

1

1

Round 5

5

1

1

 

                 

 

Bonus points 

Quick and correct answer

 

Round 1

5

4

3

2

1

       

Round 2

                 

Round 3

7

6

5

4

3

2

1

   

Round 4

8

7

6

5

4

3

2

1

 

Round 5

9

8

7

6

5

4

3

2

1

Task 5

Answer

 

4; 2

6; 0

Spain

 

     

Points

Correct answer

Country

Source Code

Round 1

1

1

1

Round 2

2

1

1

Round 3

3

1

1

Round 4

4

1

1

Round 5

5

1

1

 

                 

 

Bonus points 

Quick and correct answer

 

Round 1

5

4

3

2

1

       

Round 2

                 

Round 3

7

6

5

4

3

2

1

   

Round 4

8

7

6

5

4

3

2

1

 

Round 5

9

8

7

6

5

4

3

2

1