http://codeforces.com/contest/1006/problem/A

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;
  • ……
  • Replace each occurrence of 109−1109−1 in the array aa with 109109;
  • Replace each occurrence of 109109 in the array aa with 109−1109−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⋅108}i∈{1,2,…,5⋅108} 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] →→ (replace all occurrences of 11 with 22) →→ [2,2,4,5,10][2,2,4,5,10] →→ (replace all occurrences of 22 with 11) →→ [1,1,4,5,10][1,1,4,5,10] →→(replace all occurrences of 33 with 44) →→ [1,1,4,5,10][1,1,4,5,10] →→ (replace all occurrences of 44 with 33) →→ [1,1,3,5,10][1,1,3,5,10] →→ (replace all occurrences of 55 with 66) →→ [1,1,3,6,10][1,1,3,6,10] →→ (replace all occurrences of 66 with 55) →→ [1,1,3,5,10][1,1,3,5,10] →→ …… →→ [1,1,3,5,10][1,1,3,5,10] →→ (replace all occurrences of 1010 with 99) →→ [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.

Input

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

The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109) — the elements of the array.

Output

Print nn integers — b1,b2,…,bnb1,b2,…,bn, where bibi 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.

Examples
input

Copy
5
1 2 4 5 10
output

Copy
1 1 3 5 9
input

Copy
10
10000 10 50605065 1 5 89 5 999999999 60506056 1000000000
output

Copy
9999 9 50605065 1 5 89 5 999999999 60506055 999999999

代码:

#include <bits/stdc++.h>
using namespace std; int N;
int num[1010]; int main() {
scanf("%d", &N);
for(int i = 1; i <= N; i ++) {
scanf("%d", &num[i]);
if(num[i] % 2 == 0)
num[i] -= 1;
} for(int i = 1; i <= N; i ++) {
printf("%d", num[i]);
printf("%s", i != N ? " " : "\n");
}
return 0;
}

  

最新文章

  1. JAVA笔试题集(一)--JAVASE部分
  2. 建站技能get(1)— Asp.net MVC快速集成ckplayer网页视频播放器
  3. Websocket简单例子
  4. 原来cursor:可以这样改变鼠标样式
  5. angularjs--$watch、$watchGroup、$watchCollection含义
  6. LabVIEW设计模式系列——普遍使用值改变事件
  7. Eclipse从数据库逆向生成Hibernate带注解的实体类
  8. 二维计算几何基础题目泛做(SYX第一轮)
  9. oracle数据库连接无响应的解决
  10. openvpn实现内网 映射到 外网
  11. SAP中的BRF+
  12. H5网页后在返回到微信公众平台自定义菜单
  13. Supervisor配置
  14. Java 基础类型 默认值
  15. ACTIVE NEURAL LOCALIZATION
  16. 761A Dasha and Stairs
  17. UI设计小白怎样学才能快速入门?
  18. Linux下实现ping功能
  19. 一款纯css3实现的颜色渐变按钮
  20. [转]Loadrunner Error code 10053 &amp; Tomcat 连接器(connector)优化

热门文章

  1. 工作流性能优化(敢问activiti有扩展性?)(1)
  2. 2018.10.03 NOIP+ 模拟赛 解题报告
  3. python_输入一个数,判断是否是素数
  4. python_输出100:200内的素数
  5. 【转】浅谈Node.js单线程模型
  6. click
  7. C#的接口基础教程之五 实现接口
  8. 微服务SpringCloud+Docker入门到高级实战(目录)
  9. cocoapods 类库管理利器
  10. 七、Shell printf 命令