QOJ.ac

QOJ

Limite de temps : 5 s Limite de mémoire : 1024 MB Points totaux : 100

#3113. 混乱的通信

Statistiques

你的好朋友 Adam 最近买了一台树莓派(Raspberry Pi)和一些设备,包括一个无线温度传感器和一个用于接收传感器信号的 433MHz 接收器。Adam 计划将树莓派用作气象传感器的室内显示器。由于他非常擅长电子技术,他很快就成功让接收器接收到了传感器的信号。然而,当他查看传感器发送的字节时,却完全看不懂。在浏览了几个小时的网站后,他找到了一份文档,解释说他的气象传感器会对发送的数据进行加扰,以防止其与其他制造商的产品一起使用。

© NWERC Jury

幸运的是,该文档还描述了传感器如何对其通信进行加扰。文档指出,传感器对发送的每个字节应用表达式 $x \oplus (x \ll 1)$。其中 $\oplus$ 运算符是按位异或(XOR)$^1$,例如 $10110000 \oplus 01100100 = 11010100$。$\ll$ 运算符是字节值的(非循环)左移操作$^2$,例如 $10111001 \ll 1 = 01110010$。

为了让 Adam 的树莓派能够正确解读气象传感器发送的字节,需要对传输的数据进行解扰。然而,Adam 不擅长编程(实际上他是一个非常糟糕的程序员)。所以他请求你帮助他,而作为好朋友,你总是乐于助人。你能通过实现解扰算法来帮助 Adam 吗?

输入格式

输入包含: 一行包含一个整数 $n$ ($1 \le n \le 10^5$),表示气象传感器发送的消息中的字节数; 一行包含 $n$ 个整数 $b_1, \dots, b_n$ ($0 \le b_i \le 255$,对于所有 $i$),表示消息的字节值。

输出格式

输出 $n$ 个字节值(十进制编码),即解扰后的消息。

样例

输入格式 1

5
58 89 205 20 198

输出格式 1

22 55 187 12 66

$^1$ 在按位异或中,如果且仅当两个参数的第 $i$ 位中只有一个为 1 时,结果的第 $i$ 位才为 1。 $^2$ 在 $x \ll j$ 中,$x$ 的位向左移动 $j$ 位。$x$ 的最高 $j$ 位被丢弃,并在结果的最低位补 $j$ 个零。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.