查找 A、B 和 C 的值,使得 (A^B)+(B^C)+(C^A) 等于给定整数 X
X 是正整数。我必须找到 3 个不同的数字 A、B 和 C,使得 0 ≤ A,B,C < 230 和 (A^B)+(B^C)+(C^A)=X,其中“^”是按位异或运算符
X is positive integer.I have to find 3 distinct numbers A, B and C such that 0 ≤ A,B,C < 230 and (A^B)+(B^C)+(C^A)=X where '^' is a bitwise XOR operator
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
免责声明:我不是数学家。
有多种解决方案,本文找到其中之一。
获取 X 并将其转换为二进制(例如 20220408 - 昨天的日期)
X=1001101001000100111111000
如果最后一位数字为 1(X 为奇数),则无解
丢弃最后的0(除以2或右移)
X=100110100100010011111100
创建 3 个二进制数:从零开始,并将 X 中的每 1 位放入 a 或 b 或 c。哪一个并不重要。只是为了好玩,让我们以循环方式进行:
a=100000100000000010010000
b=000100000100000001001000
c=000010000000010000100100
注意:如果只有一个 1 位(X 是 2 的幂),a,b,c 不会不同,因为其中 2 个为零。
检查结果:
Disclaimer: I'm not an mathematician.
There are several solutions, this finds one of them.
take the X and convert it to binary (e.g 20220408 - yesterday's date)
X=1001101001000100111111000
If the last digit is 1 (X is odd), there is no solution
Discard the last 0 (divide by 2 or shift right)
X=100110100100010011111100
Create 3 binary numbers: start with zeroes and put each 1 bit from X to either a or b or c. It does not matter which one. Just for fun let's do it in a round-robin matter:
a=100000100000000010010000
b=000100000100000001001000
c=000010000000010000100100
Note: if there is only one 1 bit (X is a power of 2), a,b,c won't be distinct, because 2 of them will be zero.
Check the result: