← 返回题目列表

Codeforces · 1006/A

A. 相邻的替换品

中文机器翻译题面 查看原题

Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).

Mishka 不喜欢这份礼物,想以某种方式改变它。 He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm".该算法可以表示为一系列步骤:

- 将数组 $$$a$$$ 中每次出现的 $$$1$$$ 替换为 $$$2$$$;
- 将数组 $$$a$$$ 中每次出现的 $$$2$$$ 替换为 $$$1$$$;
- Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$;
- 将数组 $$$a$$$ 中每次出现的 $$$4$$$ 替换为 $$$3$$$;
- Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$;
- Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$;
- $$$\点$$$
- 将数组 $$$a$$$ 中每次出现的 $$$10^9 - 1$$$ 替换为 $$$10^9$$$;
- 将数组 $$$a$$$ 中出现的每个 $$$10^9$$$ 替换为 $$$10^9 - 1$$$。

请注意,该算法中间的点意味着 Mishka 对每个 $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ 的每对相邻整数 ($$$2i - 1, 2i$$$) 应用这些替换,如上所述。

例如,对于数组 $$$a = [1, 2, 4, 5, 10]$$$,以下数组序列表示算法:

$$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (将所有出现的 $$$1$$$ 替换为 $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (将所有出现的 $$$1$$$ 替换$$$2$$$ 与 $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (将所有出现的 $$$3$$$ 替换为 $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (将所有出现的 $$$6$$$ 替换为 $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$(将所有出现的 $$$10$$$ 替换为 $$$9$$$)$$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$。该算法的后续步骤不会更改数组。

Mishka is very lazy and he doesn't want to apply these changes by himself.但他对他们的结果很感兴趣。 Help him find it.

输入

输入的第一行包含一个整数 $$$n$$$ ($$$1 \le n \le 1000$$$) — Mishka 的生日礼物中的元素数量(令人惊讶的是,一个数组)。

输入的第二行包含 $$$n$$$ 整数 $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — 数组的元素。

输出

打印 $$$n$$$ 整数 — $$$b_1, b_2, \dots, b_n$$$,其中 $$$b_i$$$ 是将“Mishka 的相邻替换算法”应用于数组 $$$a$$$ 后,数组的第 $$$i$$$ 个元素的最终值。请注意,您无法更改数组中元素的顺序。

示例

输入 #1

5
1 2 4 5 10

输出 #1

1 1 3 5 9

输入 #2

10
10000 10 50605065 1 5 89 5 999999999 60506056 1000000000

输出 #2

9999 9 50605065 1 5 89 5 999999999 60506055 999999999

注意

The first example is described in the problem statement.