The image shows a grid containing two sets of 4 highlighted cells, which are populated with the numbers 1, 2, 3, 4 and 4, 3, 2, 1, respectively.
Fill the empty cells with integers from 1 to 4 such that, for each highlighted cell in the top set, there is a path to the corresponding highlighted cell in the bottom set (containing the same number) that moves only through cells containing that same number. You may not change the numbers already present in the highlighted cells.
From any given cell, you may move to an adjacent cell (up, down, left, or right) only if that cell contains the same number.
In the answer field, provide exactly 8 rows, each containing 7 numbers. Do not include any extra text! When submitting your solution, select the language "PHP" (you do not need to know PHP, it's just a feature of the system).
Each valid path between a pair of identical numbers in the highlighted cells is worth 25 points. The maximum score for this problem is 100.
For convenience, you may use spreadsheet software (such as Microsoft Excel or LibreOffice Calc) to fill in an 8x7 grid, then select the filled area and copy it into the answer field.
There are $$$N$$$ trees in a garden, arranged in a straight line. The distance between adjacent trees is one meter. The distance from the well to the first tree is also one meter. Watering one tree requires one bucket of water.
Vasya waters the trees as follows: he fills two buckets of water at the well, walks to the last two trees to water them, then returns to the well, and the process repeats.
Your task is to find a formula that calculates the total distance Vasya travels. For example, when $$$N=3$$$, your formula should yield a result of 8.
In your formula, you may use only the following elements:
The '/' operator denotes integer division (e.g., 8 / 3 = 2, -8 / 3 = -2). The '%' operator denotes the remainder (e.g., 8 % 5 = 3, -8 % 5 = -3). Multiplication, division, and remainder operations have higher precedence than addition and subtraction. The multiplication symbol cannot be omitted.
When submitting your solution, please select PHP (you don't need to know it, it's just a feature of the system).
The correctness of your formula will be verified automatically by substituting various values of $$$N$$$ (ranging from 1 to 1000) into it. Points will be awarded for each correct answer. The maximum possible score is 100.
A Markov normal algorithm defines a method for transforming an input string into a result string using a system of substitutions.
Each substitution consists of two words: a pattern and a replacement. At each step of the algorithm, the list of substitutions is scanned to find the first one where the pattern appears as a substring within the current string $$$s$$$. This substring in $$$s$$$ is then replaced by the replacement word. If the pattern appears multiple times in $$$s$$$, only the leftmost occurrence is replaced.
A pattern in a substitution may be empty; in this case, the replacement word is inserted at the very beginning of $$$s$$$. Typically, such a substitution is placed last to prevent the algorithm from entering an infinite loop. The replacement word may also be empty (effectively deleting the pattern).
The algorithm terminates in two cases: first, if no further substitutions are applicable; second, if a substitution is performed where the replacement word ends with a special symbol — a period ('.'), which is not itself inserted into the string $$$s$$$.
Consider an example. Suppose the input string consists only of the digits 0 and 1, and the task is to delete all zeros at the end of the string. The solution is:
p1 1p
p0 0p
0p p
p .
p
Let's examine how this algorithm processes the input string $$$s = \text{"10100"}$$$. First, the final substitution is applied, inserting "p" at the beginning of $$$s$$$. Now, $$$s = \text{"p10100"}$$$.
Next, the first or second substitution is applied five times, causing the symbol 'p' to "move" to the right until it reaches the end of the string. The result is $$$s = \text{"10100p"}$$$. After this, the third substitution is applied twice, replacing "0p" with "p". Now, $$$s = \text{"101p"}$$$.
Finally, the fourth substitution is applied, which deletes "p" and terminates the algorithm. As a result, $$$s = \text{"101"}$$$.
Your task. Design a Markov normal algorithm to solve the following problem. The input string $$$s$$$ contains a natural number. After the algorithm has run, the string should contain the remainder when this number is divided by 3.
In the answer field, enter your substitutions, separating the pattern (the string to be replaced) and the replacement string with a space. If the pattern is empty, insert a single space followed by the replacement string. If the replacement string is empty, simply provide the pattern (you may optionally add a space). Both the pattern and the replacement string cannot be empty at the same time.
When submitting your solution, select "PHP" in the "Language" field (you do not need to know PHP; this is simply a feature of the system).
Subtask 1 (up to 20 points): the input number consists of a single digit.
Subtask 2 (up to 35 points): the input number consists of two digits.
Subtask 3 (up to 45 points): the input number has between 3 and 9 digits.
To write and debug your program, you can use the Markov normal algorithm simulator, which can be downloaded here: https://kpolyakov.spb.ru/prog/nma.htm (the interface is in Russian only).
To copy your solution from the simulator, go to the "File" menu, select "Export program" (do not confuse this with "Save"), and export the program to a text file. Copy the entire contents of this file into the response field, or submit the file itself.
Technical constraints: no more than 100 substitutions, each substitution no longer than 20 characters, and a maximum of 1000 algorithm steps. Substitutions may only contain digits, uppercase and lowercase Latin letters, and the period character ('.').
Given a natural number $$$S$$$, determine whether it is possible to represent $$$S$$$ as a sum of consecutive integers, where the number of terms is between $$$A$$$ and $$$B$$$ (inclusive).
Three integers — $$$S$$$, $$$A$$$, and $$$B$$$ are provided, each on a separate line ($$$1 \le S \le 2 \cdot 10^9$$$, $$$1 \le A \le B \le 10^6$$$).
If a solution exists, output two integers: the first term of the sequence and the total number of terms. If multiple solutions exist, output the one where the first term is as large as possible. If no solution exists, output «NO» (without quotation marks, both letters capitalized).
Subtask 1 (up to 30 points): $$$S \le 100$$$, $$$B \le 100$$$
Subtask 2 (up to 30 points): $$$S \le 10^4$$$, $$$B \le 10^5$$$
Subtask 3 (up to 40 points): no additional constraints.
925
4 2
546
-1 5
134
NO
Vasya has forgotten his password. All he remembers is that the password had a length of $$$n$$$ and consisted only of digits, with the condition that any two adjacent digits differed by no more than one.
Determine how many possible passwords Vasya would have to try to log into the system, assuming the correct password is the very last one he checks.
A single integer $$$n$$$ ($$$2 \le n \le 25$$$) is provided, representing the length of the password.
Output a single integer — the number of possible passwords of length $$$n$$$.
Subtask 1 (up to 40 points): $$$n \le 10$$$
Subtask 2 (up to 60 points): $$$n \le 25$$$
2
28