C - Chip Factory

C - Chip Factory
Time Limit:9000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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
 
    
 
    
 
    
 
    
#include <iostream>
#include<algorithm>
using namespace std;
int a[1010];
int main()
{
       int t;
       cin>>t;
       int n;
       while(t--)
       {
             cin>>n;
             for(int i=0;i<n;i++)
                cin>>a[i];
                int flag;
                int Max=0;
             for(int i=0;i<n-2;i++)
                for(int j=i+1;j<n-1;j++)
                  for(int k=j+1;k<n;k++)
             {
                    flag=max(max((a[i]+a[j])^a[k],(a[j]+a[k])^a[i]),(a[i]+a[k])^a[j]);
                    if(flag>Max)
                        Max=flag;
             }
             cout<<Max<<endl;
       }
    return 0;
}
PS C:\Users\Czh20>docker logs ms1 Starting server: matter-server --storage-path /data 2025-07-01 10:12:59.712 (MainThread) INFO [matter_server.server.stack] Initializing CHIP/Matter Logging... 2025-07-01 10:12:59.716 (MainThread) INFO [matter_server.server.stack] Initializing CHIP/Matter Controller Stack... [1751335979.804797][1:1] CHIP:CTL: Setting attestation nonce to random value [1751335979.816668][1:1] CHIP:CTL: Setting CSR nonce to random value [1751335979.843532][1:1] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /tmp/chip_kvs [1751335979.848176][1:1] CHIP:DL: writing settings to file (/tmp/chip_kvs-zBRy7g) [1751335979.848756][1:1] CHIP:DL: renamed tmp file to file (/tmp/chip_kvs) [1751335979.852228][1:1] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_factory.ini [1751335979.865749][1:1] CHIP:DL: writing settings to file (/data/chip_factory.ini-40tu4e) [1751335979.869397][1:1] CHIP:DL: renamed tmp file to file (/data/chip_factory.ini) [1751335979.872422][1:1] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_config.ini [1751335979.875697][1:1] CHIP:DL: writing settings to file (/data/chip_config.ini-tWnmhf) [1751335979.879118][1:1] CHIP:DL: renamed tmp file to file (/data/chip_config.ini) [1751335979.881894][1:1] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_counters.ini [1751335979.884846][1:1] CHIP:DL: writing settings to file (/data/chip_counters.ini-YrZA2i) [1751335979.887942][1:1] CHIP:DL: renamed tmp file to file (/data/chip_counters.ini) [1751335979.904963][1:1] CHIP:DL: writing settings to file (/data/chip_factory.ini-cDKQbg) [1751335979.910611][1:1] CHIP:DL: renamed tmp file to file (/data/chip_factory.ini) [1751335979.911109][1:1] CHIP:DL: NVS set: chip-factory/unique-id = "F9923FF5BFC520D2" [1751335979.915341][1:1] CHIP:DL: writing settings to file (/data/chip_factory.ini-yqmzag) [1751335979.920002][1:1] CHIP:DL: renamed tmp file to file (/data/chip_factory.ini) [1751335979.920591][1:1] CHIP:DL: NVS set: chip-factory/vendor-id = 65521 (0xFFF1) [1751335979.923495][1:1] CHIP:DL: writing settings to file (/data/chip_factory.ini-UGGXIi) [1751335979.928330][1:1] CHIP:DL: renamed tmp file to file (/data/chip_factory.ini) [1751335979.928689][1:1] CHIP:DL: NVS set: chip-factory/product-id = 32769 (0x8001) [1751335979.931531][1:1] CHIP:DL: writing settings to file (/data/chip_counters.ini-Wmf1mg) [1751335979.935984][1:1] CHIP:DL: renamed tmp file to file (/data/chip_counters.ini) [1751335979.936586][1:1] CHIP:DL: NVS set: chip-counters/reboot-count = 1 (0x1) [1751335979.939562][1:1] CHIP:DL: writing settings to file (/data/chip_counters.ini-bG6gHi) [1751335979.944588][1:1] CHIP:DL: renamed tmp file to file (/data/chip_counters.ini) [1751335979.945098][1:1] CHIP:DL: NVS set: chip-counters/total-operational-hours = 0 (0x0) [1751335979.947790][1:1] CHIP:DL: writing settings to file (/data/chip_counters.ini-jbvl4f) [1751335979.952606][1:1] CHIP:DL: renamed tmp file to file (/data/chip_counters.ini) [1751335979.953050][1:1] CHIP:DL: NVS set: chip-counters/boot-reason = 0 (0x0) [1751335979.956022][1:1] CHIP:DL: writing settings to file (/data/chip_config.ini-LkjBTf) [1751335979.960702][1:1] CHIP:DL: renamed tmp file to file (/data/chip_config.ini) [1751335979.961140][1:1] CHIP:DL: NVS set: chip-config/regulatory-location = 0 (0x0) [1751335979.963806][1:1] CHIP:DL: writing settings to file (/data/chip_config.ini-oqVsTg) [1751335979.968424][1:1] CHIP:DL: renamed tmp file to file (/data/chip_config.ini) [1751335979.968875][1:1] CHIP:DL: NVS set: chip-config/location-capability = 2 (0x2) [1751335979.972117][1:1] CHIP:DL: Failed to get Ethernet interface [1751335979.972644][1:1] CHIP:DL: Failed to reset Ethernet statistic counts [1751335979.973075][1:1] CHIP:DL: Failed to get WiFi interface [1751335979.973340][1:1] CHIP:DL: Failed to reset WiFi statistic counts 2025-07-01 10:12:59.977 (MainThread) WARNING [PersistentStorage] Initializing persistent storage from file: /data/chip.json 2025-07-01 10:12:59.978 (MainThread) ERROR [root] [Errno 2] No such file or directory: '/data/chip.json' 2025-07-01 10:12:59.979 (MainThread) CRITICAL [root] Could not load configuration from /data/chip.json - resetting configuration... 2025-07-01 10:12:59.979 (MainThread) WARNING [root] No valid SDK configuration present - clearing out configuration 2025-07-01 10:12:59.980 (MainThread) WARNING [root] No valid REPL configuration present - clearing out configuration 2025-07-01 10:13:00.662 (MainThread) WARNING [CertificateAuthorityManager] Loading certificate authorities from storage... 2025-07-01 10:13:00.665 (MainThread) WARNING [CertificateAuthority] New CertificateAuthority at index 1 2025-07-01 10:13:00.702 (MainThread) WARNING [FabricAdmin] New FabricAdmin: FabricId: 0x0000000000000001, VendorId = 0xFFF1 2025-07-01 10:13:00.715 (MainThread) INFO [matter_server.server.stack] CHIP Controller Stack initialized. 2025-07-01 10:13:00.723 (MainThread) INFO [matter_server.server.server] Starting the Matter Server... 2025-07-01 10:13:00.751 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetching the latest PAA root certificates from DCL. 2025-07-01 10:13:17.987 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetched 69 PAA root certificates from DCL. 2025-07-01 10:13:39.746 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetched 83 PAA root certificates from Test DCL. 2025-07-01 10:13:39.746 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetching the latest PAA root certificates from Git. 2025-07-01 10:14:28.382 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetched 6 PAA root certificates from Git. 2025-07-01 10:14:28.387 (MainThread) WARNING [FabricAdmin] Allocating new controller with CaIndex: 1, FabricId: 0x0000000000000001, NodeId: 0x000000000001B669, CatTags: [] 2025-07-01 10:14:29.417 (Dummy-2) CHIP_ERROR [chip.native.DL] Long dispatch time: 1025 ms, for event type 2 2025-07-01 10:14:29.446 (MainThread) INFO [matter_server.server.device_controller] Loaded 0 nodes from stored configuration 2025-07-01 10:14:29.455 (MainThread) ERROR [matter_server.server] Error doing task: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiorun.py", line 219, in new_coro await coro File "/usr/local/lib/python3.11/site-packages/matter_server/server/server.py", line 164, in start await self._device_controller.start() File "/usr/local/lib/python3.11/site-packages/matter_server/server/device_controller.py", line 185, in start self._aiozc = AsyncZeroconf(ip_version=IPVersion.All) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/zeroconf/asyncio.py", line 166, in __init__ self.zeroconf = zc or Zeroconf( ^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/zeroconf/_core.py", line 180, in __init__ listen_socket, respond_sockets = create_sockets(interfaces, unicast, ip_version, apple_p2p=apple_p2p) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/zeroconf/_utils/net.py", line 374, in create_sockets respond_socket = new_respond_socket(i, apple_p2p=apple_p2p) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/zeroconf/_utils/net.py", line 341, in new_respond_socket respond_socket.setsockopt(_IPPROTO_IPV6, socket.IPV6_MULTICAST_IF, iface_bin) OSError: [Errno 92] Protocol not available PS C:\Users\Czh20>
07-02
[1656/1658] Generating binary image from built executable esptool.py v4.8.1 Creating esp32s3 image... Merged 2 ELF sections Successfully created esp32s3 image. Generated /home/jichu/esp32/lvgl_display/build/lvgl_display.bin [1657/1658] cd /home/jichu/esp32/lvgl_...32/lvgl_display/build/lvgl_display.bin lvgl_display.bin binary size 0x18b940 bytes. Smallest app partition is 0x300000 bytes. 0x1746c0 bytes (48%) free. [1657/1658] cd /home/jichu/esp32/esp-i...nents/esptool_py/run_serial_tool.cmake esptool.py --chip esp32s3 -p /dev/ttyACM0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 16MB 0x0 bootloader/bootloader.bin lvgl_display.bin 0x8000 partition_table/partition-table.bin usage: esptool write_flash [-h] [--erase-all] [--flash_freq {keep,80m,60m,48m,40m,30m,26m,24m,20m,16m,15m,12m}] [--flash_mode {keep,qio,qout,dio,dout}] [--flash_size {detect,keep,256KB,512KB,1MB,2MB,2MB-c1,4MB,4MB-c1,8MB,16MB,32MB,64MB,128MB}] [--spi-connection SPI_CONNECTION] [--no-progress] [--verify] [--encrypt] [--encrypt-files <address> <filename> [<address> <filename> ...]] [--ignore-flash-encryption-efuse-setting] [--force] [--compress | --no-compress] <address> <filename> [<address> <filename> ...] esptool write_flash: error: argument <address> <filename>: Address "lvgl_display.bin" must be a number CMake Error at run_serial_tool.cmake:66 (message): /home/jichu/.espressif/python_env/idf5.2_py3.8_env/bin/python;;/home/jichu/esp32/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32s3 failed. FAILED: CMakeFiles/flash cd /home/jichu/esp32/esp-idf/components/esptool_py && /usr/bin/cmake -D IDF_PATH=/home/jichu/esp32/esp-idf -D "SERIAL_TOOL=/home/jichu/.espressif/python_env/idf5.2_py3.8_env/bin/python;;/home/jichu/esp32/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32s3" -D "SERIAL_TOOL_ARGS=--before=default_reset;--after=hard_reset;write_flash;@flash_args" -D WORKING_DIRECTORY=/home/jichu/esp32/lvgl_display/build -P /home/jichu/esp32/esp-idf/components/esptool_py/run_serial_tool.cmake ninja: build stopped: subcommand failed. ninja failed with exit code 1, output of the command is in the /home/jichu/esp32/lvgl_display/build/log/idf_py_stderr_output_42355 and /home/jichu/esp32/lvgl_display/build/log/idf_py_stdout_output_42355
03-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值