Chip Factory
Time Limit: 18000/9000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1842 Accepted Submission(s): 833
Problem Description
John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of products, every processor has a serial number. More specifically, the factory produces chips today, the -th chip produced this day has a serial number .At the end of the day, he packages all the chips produced this day, and send it to wholesalers. More specially, he writes a checksum number on the package, this checksum is defined as below: which are three different integers between and . And is symbol of bitwise XOR.Can you help John calculate the checksum number of today?
Input
The first line of input contains an integer indicating the total number of test cases.The first line of each test case is an integer , indicating the number of chips produced today. The next line has integers , separated with single space, indicating serial number of each chip.There are at most testcases with
Output
For each test case, please output an integer indicating the checksum number in a line.
Sample Input
2 3 1 2 3 3 100 200 300
Sample Output
6 400
给你n个整型数(n<=1e3),现在可以从其中选出s1,s2,s3三个数字,要求求出(s1+s2)^s3的最大值,至多
1e3组测试数据。
#include#include #include #include #include #include #include
错因:刚开始想到的是枚举下s1+s2,然后,,插入s3,,,但是发现根本处理不了重合的情况,,,。。
解答:其实先依次添加元素建好字典树后,,可以n^2的枚举s1+s2,同时在字典树中抹去这两个元素,
这时再插入s3,,每次操作完成后都将s1,s2再添加进去。。