编程介的小学生 2017-10-29 12:46 采纳率: 20.5%
浏览 766
已采纳

Overt

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

Sample Output
4292342015
4294967295

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-19 08:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号