CONTINUE...?

点击打开链接

题意:t组实例,每组实例一个n,表示字符串的长度,给你一个只含'0'和'1'组成的字符串,'0'表示女生,'1'表示男生,从1开始,位于i位上的人有价值为i的宝石,给他们分组,女生分为1、2组,男生分为3、4组,怎样分组可以使1、3组宝石总价值等于2、4组宝石总价值,不能分则输出-1;

思路:就是把分给左右两队,不用管她是男是女,只要宝石保持左右两边相等,然后再考虑是男是女分给(1,2)还是(3,4).

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
char s[100010];
long long int a[100010],sum;
int main()
{
    long long int t,n,i,j;
    scanf("%lld",&t);
    while(t--)
    {
        int flag=1;
        scanf("%lld",&n);
        scanf("%s",s);
        if(n<=2)
            flag=0;

        sum=n*(n+1)/2;
        if(sum&1)
            flag=0;

        if(flag)
        {

            if(n%2==1)
            {
                s[n-1]=s[n-1]=='0'?'1':'3';  //1+3=2+4
                s[n-2]=s[n-2]=='0'?'2':'4';
                s[0]=s[0]=='0'?'2':'4';
                for(i=1,j=2; i<(n-2)/2;)
                {
                    s[i]=s[i]=='0'?'1':'3';//左
                    s[n-2-i]=s[n-2-i]=='0'?'1':'3';

                    s[j]=s[j]=='0'?'2':'4';//右
                    s[n-2-j]=s[n-2-j]=='0'?'2':'4';
                    i=j+1;
                    j=i+1;
                }
            }
            else
            {
                for(i=0,j=1; i<(n/2)&&j<(n/2);)
                {
                    s[i]=s[i]=='0'?'1':'3';
                    s[n-1-i]=s[n-1-i]=='0'?'1':'3';

                    s[j]=s[j]=='0'?'2':'4';
                    s[n-1-j]=s[n-1-j]=='0'?'2':'4';
                    i=j+1;
                    j=i+1;
                }
            }
        }
        if(flag)
            puts(s);
        else
            printf("-1\n");
    }
    return 0;
}
Using: Intel (R) PRO Network Connections SDK v2.30.10 EEUPDATE v5.30.10.00 Copyright (C) 1995 - 2017 Intel Corporation Intel (R) Confidential and not for general distribution. ----------------------------------------------------- Options: /HELP or /? Displays command line help. /EXITCODES Displays exit code help. /ALL Selects all adapters found in the system. /NIC=XX Selects a specific adapter (1-32). /BUS=XX Selects PCI bus of adapter to program. Must be used with the DEV parameter to specify an adapter. /DEV=XX Selects PCI device of the adapter to program. Must be used with the BUS parameter to specify an adapter. /FUN=XX Selects PCI function of the adapter to program. Must be used with both the BUS and DEV parameters to specify an adapter. Press to continue... /DEVICE= 4 hex digit device id of card to program. /SUBDEVICE= 4 hex digit subsystem device id of card to program. /DUMP Dumps EEPROM/Shadow RAM memory contents to file *.eep and flash memory to *.bin (if available) /MAC_DUMP_FILE Dumps the MAC address to a file usable by the /A command. /MAC_DUMP Displays the adapter LAN MAC address. /MAC_DUMP_ALL Displays all the MAC addresses. /MAC_ALL_TO_FILE Dumps all the MAC addresses to a file usable by the /MAC_ALL_FROM_FILE command. /MAC_ALL_FROM_FILE Programs all MAC addresses from text file to a device. File should contain 13 MAC addresses (9 for PEPs and 4 custom MAC addresses), one each line. EUI48 and EUI64 formats accepted. /CB Clears bits in the EEPROM, specified in . /SB Sets bits in the EEPROM, specified in . Press to continue... /RW Reads from the EEPROM. /WW Writes into in EEPROM. /MAC=macaddr [/NUM=PF_num] Programs the EEPROM/NVM with only the MAC address of macaddr without changing the rest of the EEPROM/NVM. /NUM is optional and I40E specific - it defines target PF. /A or /address Programs the EEPROM/NVM with only the MAC address from the without changing the rest of the EEPROM. /D or /DATA Programs the NVM [EEPROM/FLASH] with the contents of without changing the MAC address. /PHYNVM Programs the PHY NVM with the contents of /DEBUG Forces debug update to be used where applicable. Must be used with /D or /DATA switch. /CALCCHKSUM Forces the EEPROM checksum and CRCs to be updated. Press to continue... /EEPROMVER Displays the version of the EEPROM image. /INVMVERSION Displays the version of the iNVM image. /PCIINFO Displays the PCI information of the adapter. /ADAPTERINFO Displays additional information about the adapter, such as EtrackID, PF MAC address, or image and firmware version. /TEST Checks the EEPROM/NVM checksum(s) and size. /IDFLASH Displays the flash ID and its protected status. /VERSION Displays version and the diagnostic library information. /PHYID Programs the PHY ID NVM with the contents of . /PHYID_DUMP Dumps PHY ID NVM contents to a file with the name: _.bin /PHYID_VERIFY Verifies the PHY ID NVM image in eeprom against the file specified in . Press to continue... /FLASH_DUMP Dumps contents of the whole flash memory of selected adapters to *.bin file /EEPROM_DUMP Dumps contents of the EEPROM/Shadow RAM memory of selected adapters to *.eep file /GUI Brings up GUI mode. /GUI /HELP Displays GUI help. /NOPROT When programming an image for devices that support NVM protection, prevents protection from being enabled. This switch must be used with the /DATA command and has no effect on NVM devices that are already protected. /DEBUGLOG Log debug messages into the debugfile. /VERIFY Verifies the eeprom/NVM image in eeprom/NVM to the target file specified in . Press to continue... /CHECKIMAGE Verifies that the NVM in can be loaded over the running NVM. /VERIFYPHYNVM Verifies the PHY NVM image in eeprom to the target file specified in . /ADAPTERRESET Reset the adapter. *CAUTION* This will unload the driver for this device if present. /SANMAC_DUMP [/NUM=PF_num] Displays the dedicated MAC address for the SAN. /NUM is optional and i40e specific - it defines target PF. /SANMAC=macaddr [/NUM=PF_num] Programs the dedicated SAN MAC address withoutchanging the rest of the EEPROM. /NUM is optional and i40e specific - it defines target PF. /SANADDRESS Programs the dedicated SAN MAC address with the MAC address from . /INVMVERIFY /FILE=] Compares autoload configuration stored in OTP memory with the configuration defined in configuration file. /INVMTEST /FILE=] Report number of free space left in INVM if autoload configuration defined in configuration file would be applied. Press to continue... /INVMUPDATE /FILE=] Write new autoload configuration defined in Raw (*.raw) configuration file to empty INVM or updates current autoload configuration stored in INVM based on 'human readable' configuration file. /INVMISLOCKED Checks if autoload configuration stored in OTP memory is protected against write attempts. /INVMLOCK Sets unique record in autoload configuration stored in INVM protecting its content against further updates. /INVMGET Dumps autoload configuration stored in INVM to file with predefined name .otp. /FORCE Omits any warnings and forces command execution. /KEEPCONFIG This option lets you keep config words while upgrading eeprom. /PORT_MAC=macaddr /NUM=Port_num Programs the dedicated Port MAC address without changing the rest of the EEPROM. /PORT_MAC_DUMP /NUM=Port_num Display the adapter port MAC address. Press to continue... /CUSTOM_MAC mac_number mac_addr Programs the given custom mac address number [0-3] without changing the rest of the NVM (EUI48 and EUI64 formats supported). /SERIAL_MAC=macaddr Programs the dedicated PCIe serial MAC address without changing the rest of the EEPROM. /SERIAL_MAC_DUMP Display the adapter PCIe serial MAC address. /PF_MAC=macaddr /NUM=PF_num Programs the dedicated MAC address of a specified Physical Function This allows altering the mac addresses of inactive functions of a visible NIC. /PF_MAC_DUMP /NUM=PF_num Display MAC address of a selected Physical Function of the specified NIC. This allows dumping MAC addresses of inactive functions of a visible device. /MNG_MAC=macaddr /NUM=MNG_num Programs the dedicated MAC address of a specified Manageability Function This allows altering the mac addresses of inactive functions of a visible NIC. /MNG_MAC_DUMP /NUM=MNG_num Display MAC address of a selected Manageability Function of the specified NIC. This allows dumping MAC addresses of inactive functions of a visible device. /RO Programs RO words in EEPROM/SR with values taken from RO Module binary file.
<think>嗯,用户这次想查询一个名为"continue.c"的文件信息。从上下文看,用户可能是个C语言学习者或开发者,正在查找特定代码文件。不过引用中并没有直接提到"continue.c"这个文件,需要关联分析。 用户提供的四个引用里,引用[3]提到"Continue"是一个IDE插件,但这是工具名而非文件名;引用[4]标题写着"C语言常用代码(To be continue...)",这里的"continue"明显是"待续"的意思。其他引用都是普通C代码示例。 考虑到用户明确要查文件,可能需要提醒几个关键点: 第一,标准C库没有continue.c这个官方文件,它很可能是用户自定义文件 第二,常见包含"continue"关键字的代码多是循环控制示例,比如在for循环中跳过特定迭代 第三,引用[4]的"To be continue"提示可能是未完成的代码集合 用户可能混淆了"Continue"插件和本地代码文件。既然用户坚持要查,我应当提供典型用法模板而非具体内容,毕竟真实场景的continue.c功能完全取决于作者意图。可以补充说明:如果这是用户自己的文件,建议在项目目录用find命令搜索;如果是开源项目部分,需要更多上下文才能定位。 在代码示例上,给出带continue语句的循环控制示范比较稳妥,这样无论用户是想学习continue关键字用法,还是真的找某个同名文件,都能获得有效信息。同时提醒命名惯例——重要代码文件尽量用有意义的名称而非通用词汇。 </think>根据引用内容分析,`continue.c` 文件并未在提供的引用中直接出现,但结合上下文可推测其可能的用途及典型代码结构。以下是综合推断: --- ### **1. 功能推测** `continue.c` 很可能是一个 **演示 `continue` 关键字用法** 的C语言示例文件,用于展示在循环中跳过当前迭代的常见场景(如跳过特定条件的数据)。 --- ### **2. 典型代码结构示例** ```c #include <stdio.h> int main() { for (int i = 1; i <= 10; i++) { // 跳过偶数 if (i % 2 == 0) { continue; // 直接进入下一次循环 } printf("%d ", i); // 仅输出奇数:1,3,5,7,9 } return 0; } ``` #### **代码解析** - 当 `i` 为偶数时,`continue` 跳过本次循环的后续代码(不执行 `printf`); - 输出结果:`1 3 5 7 9`。 --- ### **3. 使用方法** 1. **编译**(以GCC为例): ```bash gcc continue.c -o continue ``` 2. **运行**: ```bash ./continue # Linux/macOS continue.exe # Windows ``` --- ### **4. 实际应用场景** - **数据过滤**:处理日志时跳过无效条目 - **算法优化**:跳过无需计算的中间步骤(如搜索中剪枝) - **输入校验**:忽略非法输入并继续读取 --- ### **注意事项** - 若引用[4]中的 `C语言常用代码(To be continue...)` 暗示待补充内容,`continue.c` 可能是某个开源项目的部分代码,需结合项目上下文分析功能[^4]。 - 标准C库**无**`continue.c`文件,此名称通常为用户自定义的教学或工具文件。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

2020/3/16

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值