编程介的小学生 2019-03-29 22:51 采纳率: 20.5%
浏览 294

关于算术运算符和位运算符的一个问题,采用C语言程序的技术来编写程序

Problem Description
Carelessly designed cryptographic primitives leave your secret as bared as plain text. It is not a surprise that seemingly "random" hash functions are weak. Consider the function of the following form:

unsigned int hash(unsigned int x) {
x += 0x327b7473u;
x &= 0xffffafffu;
x ^= 0x90283712u;
x |= 0x00300000u;
x += 0x89129723u;
x ^= 0x464726ccu;
x &= 0xfffff8ffu;
//......
return x;
}

The function maps an integer to another integer and intends to make the result random. All statements are of the form: x (some operator) (some number). Possible operators are: add (+=), subtract (-=), bitwise-and (&=), bitwise-xor (^=), and bitwise-or (|=). Due to the nature of fixed size integer, there is an implicit modulo 4294967296 operation after each statement.

However, it is a rather weak hash function from a cryptographic point of view. To demonstrate its weakness, you are requested to find an input x that maximizes the output.

In this example the best x is 1841992591 and the maximum output is 4292342015.

Input
The first line contains an integer T, denoting the number of the test cases.

Each test case begins with a non-negative integer N, the number of operations in the hash function. 0<=N<=40.

Then follows N lines, each describing an operation. Each line contains an operator and an 8-digit hexadecimal number.

Output
For each test case, output the maximum output in decimal format.

Sample Input
2
7
+= 327b7473
&= ffffafff
^= 90283712
|= 00300000
+= 89129723
^= 464726cc
&= fffff8ff
1
-= 00000001

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 树莓派安卓APK系统签名
    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗