CF1006A.Adjacent Replacements

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps:

  • Replace each occurrence of 11 in the array aa with 22;
  • Replace each occurrence of 22 in the array aa with 11;
  • Replace each occurrence of 33 in the array aa with 44;
  • Replace each occurrence of 44 in the array aa with 33;
  • Replace each occurrence of 55 in the array aa with 66;
  • Replace each occurrence of 66 in the array aa with 55;
  • …\dots
  • Replace each occurrence of 109−110^9 - 1 in the array aa with 10910^9;
  • Replace each occurrence of 10910^9 in the array aa with 109−110^9 - 1.

Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers (2i−1,2i2i - 1, 2i) for each i∈1,2,…,5⋅108i \in{1, 2, \ldots, 5 \cdot 10^8} as described above.

For example, for the array a=[1,2,4,5,10]a = [1, 2, 4, 5, 10], the following sequence of arrays represents the algorithm:

[1,2,4,5,10][1, 2, 4, 5, 10] →\rightarrow (replace all occurrences of 11 with 22) →\rightarrow [2,2,4,5,10][2, 2, 4, 5, 10] →\rightarrow (replace all occurrences of 22 with 11) →\rightarrow [1,1,4,5,10][1, 1, 4, 5, 10] →\rightarrow (replace all occurrences of 33 with 44) →\rightarrow [1,1,4,5,10][1, 1, 4, 5, 10] →\rightarrow (replace all occurrences of 44 with 33) →\rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] →\rightarrow (replace all occurrences of 55 with 66) →\rightarrow [1,1,3,6,10][1, 1, 3, 6, 10] →\rightarrow (replace all occurrences of 66 with 55) →\rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] →\rightarrow …\dots →\rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] →\rightarrow (replace all occurrences of 1010 with 99) →\rightarrow [1,1,3,5,9][1, 1, 3, 5, 9]. The later steps of the algorithm do not change the array.

Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it.

米什卡收到了一个长度为 nn 的整数数组 aa 作为生日礼物(真是个惊喜!)

米什卡不喜欢这份礼物,想对它做些改动。他发明了一种算法,并将其命名为“米什卡的相邻替换算法”。该算法可表示为一系列步骤:

  • 将数组 aa 中每个出现的 11 替换为 22;
  • 将数组 aa 中每个出现的 22 替换为 11;
  • 将数组 aa 中每个出现的 33 替换为 44;
  • 将数组 aa 中每个出现的 44 替换为 33;
  • 将数组 aa 中每个出现的 55 替换为 66;
  • 将数组 aa 中每个出现的 66 替换为 55;
  • …\dots
  • 将数组 aa 中每个出现的 109−110^9 - 1 替换为 10910^9;
  • 将数组 aa 中每个出现的 10910^9 替换为 109−110^9 - 1。

注意:该算法中间的省略号表示米什卡对每一对相邻整数 (2i−1,2i)(2i - 1, 2i)(其中 i∈{1,2,…,5⋅108}i \in \{1, 2, \ldots, 5 \cdot 10^8\})均按上述方式执行这些替换操作。

例如,对于数组 a=[1,2,4,5,10]a = [1, 2, 4, 5, 10],以下数组序列代表了该算法的执行过程:

[1,2,4,5,10][1, 2, 4, 5, 10] →\rightarrow(将所有 11 替换为 22)→\rightarrow [2,2,4,5,10][2, 2, 4, 5, 10] →\rightarrow(将所有 22 替换为 11)→\rightarrow [1,1,4,5,10][1, 1, 4, 5, 10] →\rightarrow(将所有 33 替换为 44)→\rightarrow [1,1,4,5,10][1, 1, 4, 5, 10] →\rightarrow(将所有 44 替换为 33)→\rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] →\rightarrow(将所有 55 替换为 66)→\rightarrow [1,1,3,6,10][1, 1, 3, 6, 10] →\rightarrow(将所有 66 替换为 55)→\rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] →\rightarrow …\dots →\rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] →\rightarrow(将所有 1010 替换为 99)→\rightarrow [1,1,3,5,9][1, 1, 3, 5, 9]。算法后续的步骤不再改变该数组。

米什卡非常懒,不愿亲自执行这些变换。但他对最终结果极为感兴趣。请帮助他找出该结果。

输入格式

The first line of the input contains one integer number nn (1≤n≤10001 \le n \le 1000) — the number of elements in Mishka's birthday present (surprisingly, an array).

The second line of the input contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \le a_i \le 10^9) — the elements of the array.

输入的第一行包含一个整数 nn(1≤n≤10001 \le n \le 1000)—— 表示 Mishka 生日礼物中元素的个数(出人意料地,这是一个数组)。

输入的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \le a_i \le 10^9)—— 表示该数组的元素。

输出格式

Print nn integers — b1,b2,…,bnb_1, b_2, \dots, b_n, where bib_i is the final value of the ii-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array aa. Note that you cannot change the order of elements in the array.

输出 nn 个整数 — b1,b2,…,bnb_1, b_2, \dots, b_n,其中 bib_i 表示对数组 aa 应用“Mishka 的相邻替换算法”后,数组中第 ii 个元素的最终值。注意:你不能改变数组中元素的顺序。

输入输出样例

  • 输入#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.

第一个示例在题目描述中已给出。

输入解题思路,AI测评打分。不知道怎么写?

首页