J - Joyless Game Kattis - joylessgame(找规律)

本文介绍了Joyless Game Kattis的玩法,这是一个字母字符串删除游戏,玩家轮流删除字符,条件是不能删除首尾字符且新字符串中不能有连续相同的字符。Chikapu首先开始,但在多次游戏中总是输。问题在于确定如果双方都发挥最优水平,哪一方会获胜。输入包含多个测试用例,每个用例给出一个字符串S,输出应为获胜者的名字。

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

J - Joyless Game Kattis - joylessgame (找规律)

Playing games is the best way to improve flexibility, critical thinking and strategy.

To become the best Pokenom player, Bash is playing some games with his Pokenom Chikapu.

Bash writes down a string S containing only lowercase English letters. No 2 consecutive characters in S are equal.

Bash and Chikapu alternatively take turns to play.

In each turn, a player must delete one character in S. There are 2 conditions:

The first and last characters can not be deleted.

After the character is deleted, in the new string, no 2 consecutive characters are equal.

The player who cannot delete a character loses.

Chikapu plays first.

After playing 109+7 games, Chikapu won 0 games and lost all 109+7 times. Chikapu thinks that Bash is cheating, by selecting a string S such that Bash always wins.

Given some string S, can you help determine who would win the game, if they both play optimally?

Input
The first line of input contains the integer T — the number of test cases (1≤T≤20).

The next T lines each contain exactly one string S (3≤|S|≤105).

Output
For each test case, print on one line the name of the winner, if they both play optimally. Please note that this problem uses case-sensitive checker.

Sample Input 1
2
vietnam
icpc
Sample Output 1
Chikapu
Bash

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        string s;
        cin >> s;
        if(s[0]==s[s.size()-1])
        {
            if(s.size()%2==0)
            {
                cout << "Chikapu" <<endl;
            }
            else
            {
                cout << "Bash" << endl;
            }
        }
        else
        {
            if(s.size()%2!=0)
            {
                cout << "Chikapu" <<endl;
            }
            else
            {
                cout << "Bash" << endl;
            }
        }
    }
    return 0;
}

内容概要:本文详细介绍了威纶通触摸屏与施耐德ATV12变频器之间的Modbus通讯方法,涵盖硬件接线、参数设置、控制程序编写以及调试技巧。首先,文章讲解了正确的硬件连接方式,强调了接线规范和注意事项,如使用带屏蔽的双绞线并确保正确接地。接着,针对ATV12变频器的具体参数设置进行了详尽说明,包括通信模式的选择、波特率、校验位等重要参数的配置。随后,文章展示了如何在威纶通触摸屏上创建Modbus RTU设备,并提供了具体的配置参数和控制命令示例。此外,文中还分享了一些常见的调试问题及其解决办法,如通讯超时、频率设定异常等。最后,给出了实用的调试建议,如使用串口助手抓包分析和加入通讯心跳检测等功能。 适合人群:从事工业自动化领域的工程师和技术人员,尤其是那些负责PLC编程、HMI界面开发以及设备集成工作的专业人员。 使用场景及目标:适用于需要将威纶通触摸屏与施耐德ATV12变频器进行Modbus通讯连接的实际工程项目中,帮助技术人员顺利完成设备间的通讯配置,确保系统稳定可靠运行。 其他说明:本文不仅提供了详细的理论指导,还结合了丰富的实践经验,能够有效地提高读者在实际工作中解决问题的能力。同时提醒读者,在进行相关操作前务必仔细阅读官方文档,避免因误操作造成不必要的损失。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值