Chip Factory

博客给出题目,要求在给定数组中找出三个数a[i]、a[j]、a[k],使(a[i]+a[j])^a[k]结果最大,并给出题目链接,还提到可采用暴力解法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目大意:给定数组找出三个数a[i],a[j],a[k];使的(a[i]+a[j])^a[k]最大

http://acm.hdu.edu.cn/showproblem.php?pid=5536

可以暴力。。。。。。

#include <bits/stdc++.h>
using namespace std;
int a[2000];
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        int mmax=0;
        for(int i=0;i<=n-1;i++)
            scanf("%d",&a[i]);
        for(int i=0;i<=n-1;i++)
            for(int j=i+1;j<=n-1;j++)
                for(int k=j+1;k<=n-1;k++){
                    mmax=max(mmax,(a[i]+a[j])^a[k]);
                    mmax=max(mmax,(a[i]+a[k])^a[j]);
                    mmax=max(mmax,(a[j]+a[k])^a[i]);
                }
        printf("%d\n",mmax);
    }
}

 

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值