round 557div2 E. Thanos Nim

本文解析了一种博弈论游戏的策略,游戏设定为两玩家轮流从n堆石子中取石子,每次可从n/2堆中取任意数量,先使石子堆数少于n/2者为负。通过分析,得出当最小石子堆数大于n/2时,Bob必胜;反之,Alice可模仿对手策略确保胜利。

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

题意:给出n堆石子,每次可以从n/2堆里取任意多个,当石子少于n/2堆时,现在拿石子的人输。

思路:当有一个人把任意一堆石子拿完时,它是必败的,因为另一个可以把另外的n/2堆石子拿完,则剩下不足n/2堆。由于n都是偶数,则可以从2开始打表,发现,若对所有石子排序后,若最小的石子堆数大于n/2时,必定bob赢。

当最少的石子堆数小于等于n/2时,先手可以将后一半石子拿的和前一半一样,然后就模仿后手拿的策略,最后一定后手走到必败态,先手赢。

当最少的石子堆数大于n/2时,无论先手怎么取,后手只要保证它拿n/2堆石子与先手取完后的最小堆数量一致即可,那么先手必定会先拿空一堆,先手必败。

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

int main () {
    int n, a[1000];
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    if(a[0] == a[n / 2])
        cout << "Bob" << endl;
    else
        cout << "Alice" << endl;
    return 0;
}

 

com.tongweb.deploy.interfaces.DeployException: com.tongweb.deploy.interfaces.DeployException: com.tongweb.web.thanos.startup.DeployInnerWebtierException: com.tongweb.web.thanos.startup.DeployInnerWebtierException: java.lang.IllegalStateException: ContainerBase.addChild: start: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'docTableServiceImpl' for bean class [com.ruoyi.system.service.impl.DocTableServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.ruoyi.oracle.service.impl.DocTableServiceImpl]--------this exception is deploy,exception occur is in exceptionWebtierInnerPhaserootcause is java.lang.IllegalStateException: ContainerBase.addChild: start: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'docTableServiceImpl' for bean class [com.ruoyi.system.service.impl.DocTableServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.ruoyi.oracle.service.impl.DocTableServiceImpl]--------this exception is deploy,exception occur is in exceptionWebtierInnerPhaserootcause is com.tongweb.web.thanos.startup.DeployInnerWebtierException: java.lang.IllegalStateException: ContainerBase.addChild: start: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'docTableServiceImpl' for bean class [com.ruoyi.system.service.impl.DocTableServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.ruoyi.oracle.service.impl.DocTableServiceImpl]--------this exception is deploy,exception occur is in exceptionWebtierInnerPhaserootcause is java.lang.IllegalStateException: ContainerBase.addChild: start: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'docTableServiceImpl' for bean class [com.ruoyi.system.service.impl.DocTableServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.ruoyi.oracle.service.impl.DocTableServiceImpl]--------this exception is deploy,exception occur is in exceptionWrapperPhase-------报这个错了
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值