前言

异或(XOR)是一种逻辑运算符,用于比较两个二进制数字位。当两个二进制数字位相同时,异或结果为0;当两个二进制数字位不同时,异或结果为1。在计算机科学中,异或常被用于加密、检验和、错误检测和位操作等方面。

异或算法如下:

1.如果两个数的当前位值相同,则该位结果为0。

2.如果两个数当前位值不同,则该位结果为1。

例如,我们要计算二进制数字1010和1100之间的异或结果:

1010
1100

0110

因此,1010异或1100的结果是0110。

以下是一些异或的案例:

1.将两个数字交换

a = 5
b = 3

a = a ^ b
b = a ^ b
a = a ^ b

现在,a的值变为3,而b的值变为5。

2.检查一个数字是否为奇数/偶数

如果一个数字的二进制表示的最后一位是1,则该数字为奇数。如果一个数字的二进制表示的最后一位是0,则该数字为偶数。

if (x ^ 1 == x + 1) {
// x是偶数
} else {
// x是奇数
}

3.在不使用第三方变量的情况下交换两个字符串

a = “hello”
b = “world”

a = a ^ b
b = a ^ b
a = a ^ b

现在,a的值变为”world”,而b的值变为”hello”。

一、美女与野兽

1.打开题目

在这里插入图片描述

2.解题

1
You are in this GAME. A critical mission, and you are surrounded by the beauties, ready to shed their slik gowns on your beck. On onside your feelings are pulling you apart and another side you are called by the duty. The biggiest question is seX OR success? The signals of subconcious mind are not clear, cryptic. You also have the message of heart which is clear and cryptic. You just need to use three of them and find whats the clear message of your Mind... What you must do?

就是一个xor操作:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.io.*;
public class C1{
public static void main(String[] args) throws Exception{
File a=new File("Heart_clear.txt");
File b=new File("Heart_crypt.txt");
File c=new File("Mind_crypt.txt");
InputStream isA=new FileInputStream(a);
InputStream isB=new FileInputStream(b);
InputStream isC=new FileInputStream(c);
int x,y,z;
while( (z=isC.read())!=-1){
x=isA.read();
y=isB.read();
System.out.print((char)(x^y^z));
}
isA.close();
isB.close();
isC.close();
}
}

得到 一个网页地址 https://play.google.com/store/apps/collection/promotion_3001629_watch_live_games?hl=en

Flag: Never Miss a Game