Canadian Informatics Workshop: 2025 Day 2, Problem 1
Ernest has a special dartboard that can be represented as an
grid, where
and
are odd. The rows are numbered from
to
, and the columns from
to
. For the cell in the
row and
column, we denote its value by
. For this specific grid,
equals the concatenation
of
and
. Some examples are
and
.
Ernest wants to throw a dart to hit the center of the dartboard. However, the center of this dartboard is defined a bit strangely; instead of the geometric center, it is defined as the cell containing the median value in the grid.
Help Ernest determine what the median value is!
Input Specification
The first and only line of input contains two space-separated integers
and
. It is guaranteed that
and
are odd.
The following table shows how the available 25 marks are distributed:
Marks Awarded | Bounds on |
Bounds on |
---|---|---|
2 marks | ||
3 marks | ||
4 marks | | |
8 marks | ||
8 marks |
Output Specification
On a single line, output the median value of all values in the grid.
Sample Input 1
3 5
Sample Output 1
23
Explanation for Sample Output 1
The dartboard looks like:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The median value is .
Sample Input 2
1023 957
Sample Output 2
453512
Comments