HDU 4155 The Game of 31 (博弈)

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

题意:

1,2,3,4,5,6424,2,31,,

分析:

:
,
,

31,

代码:

//
//  Created by TaoSama on 2015-11-21
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int card[10];
char s[20];

bool dfs(int sum) {
    if(sum == 31) return false;
    for(int i = 1; i <= 6; ++i) {
        if(sum + i > 31) break;
        if(!card[i]) continue;
        --card[i];
        bool F = dfs(sum + i);
        ++card[i];
        if(!F) return true;
    }
    return false;
}

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%s", s) == 1) {
        for(int i = 1; i <= 6; ++i) card[i] = 4;
        int sum = 0;
        int n = strlen(s);
        for(int i = 0; i < n; ++i) {
            --card[s[i] - '0'];
            sum += s[i] - '0';
        }
        printf("%s ", s);
        //这里必败和必胜反过来了
        if(dfs(sum)) printf("%c\n", "AB"[n & 1]); //必败
        else printf("%c\n", "BA"[n & 1]);  //必胜
    }
    return 0;
}
别再对着手册发愁了!手把手教你用西门子S7-200Smart读写汇川伺服速度参数(附完整Modbus-RTU报文解析) 本文详细介绍了西门子S7-200Smart PLC通过Modbus-RTU协议与汇川伺服驱动器进行通讯的实战方法,包括硬件连接、参数配置、报文解析及PLC编程。重点解析了速度参数的读写操作,并提供了完整的Modbus-RTU报文示例和常见问题排查指南,帮助工程师快速掌握工业自动化现场调试技巧。 阅读详情

相关推荐

免扩散生成:基于闭式分数场的即时模仿学习原理与工业落地

扩散模型的核心在于对数据分布梯度(即分数)的建模与利用。传统扩散推理依赖多步随机采样,而‘免扩散’并非跳过学习过程,而是通过构建可解析、可微分的闭式分数场,在单步内完成高质量生成。其技术价值在于突破推理延迟瓶颈,满足手机端滤镜、工业质检、车载视觉等毫秒级响应场景需求;关键挑战在于分数场建模的流形一致性、局部可解性与外推鲁棒性。本文聚焦分数场建模能力与即时模仿学习对齐机制两大热词,结合保角映射、流形自适应分块、在线扩展等工程实践,系统拆解从理论分数到工业级免扩散策略的全链路落地逻辑。

weixin_30439067的博客 435

ZOJ1827 HDU4155 The Game of 31博弈论+爆搜

爆搜吧,数据量不大,没必要用记忆化 /******************************************************************************* # Author : Neo Fung # Email : neosfung@gmail.com # Last modified: 2012-06-21 17:50 # Filenam

Neo Fung的专栏 1297

【记忆化搜索】 HDU-4155-The Game of 31

本题是一道博弈题,虽然之前弄过有关博弈方面的算法,但基本都忘了,所以就用记忆搜索水过了…… 思路:开一个八位数组dp[s][a1][a2][a3][a4][a5][a6][d],其中s代表的是31减去之前玩过的卡片加起来的总和的差,a1,a2,a3,a4,a5,a6分别代表1,2,3,4,5,6六个数的张数,d表示当前是谁玩…… #include #include #include usi

AndRing的专栏 629

hdu4155 The Game of 31------sg dfs

The Game of 31 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 334    Accepted Submission(s): 168 Problem Description The game of 31 wa

Shirley 2366

The Game of 31 (博弈)

这次在湖大oj上做的,开始wa了几次,后来想到空串的情况,加了特判才A。真叫人蛋疼。。 #include #include int dp[35][5][5][5][5][5][5]; int visit[35][5][5][5][5][5][5]; int a[7]; int max(int x,int y) { return x>y?x:y; } int dfs(in

bigman_123的专栏 587

Hdu4155The Game of 31(DFS+博弈)

The Game of 31 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 563    Accepted Submission(s): 268 Problem Description The game of 3

无奈滴微笑 1046

hdu 4155 The Game of 31

题目链接:点这里。Problem DescriptionThe game of 31 was a favourite of con artists who rode the railroads in days of yore. The game is played with a deck of 24 cards: four labelled each of 1, 2, 3, 4, 5, 6. The

温文尔雅 543

hdu4155 The Game of 31

The Game of 31 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 480 Accepted Submission(s): 234 Problem Description The game of 31 was a fa

习惯与规则决定命运 1272

poj 4155 The Game of 31

http://acm.hdu.edu.cn/showproblem.php?pid=4155 题目大意: 1,2,3,4,5,6 大小的牌 各有4张 已经选了一些 可能继续选,可能不继续 问谁会赢 思路: 无论该谁选 他的所有可供选择的牌中 只要有一张牌使他胜利(使对方输) 他就会胜利 否则就会输 注意: 输入用scanf(); 代码及其注释: #include<io...

weixin_30326745的博客 129

博弈论里摸爬滚打

听说学会了博弈论就能在小伙伴面前装逼? sto 秦岳神犇——博弈论之神 orz 刷题表: HDU1079&amp;POJ1082&amp;ZOJ1024 Calendar Game HDU1525&amp;POJ2348 Euclid’s Game &nbsp; HDU1564 Play a game HDU1846 Brave Game &nbsp; HDU1847 Goo...

ShadyPi的IT笔记 931

博弈

HDU1079&POJ1082&ZOJ1024 Calendar Game HDU1525&POJ2348 Euclid's Game 多阶段博弈问题,先取到有多个选择状态的人赢HDU1564 Play a gameHDU1846 Brave GameHDU1847 Good Luck in CET-4 Everybody!HDU2147 kiki's gameHDU2...

weixin_30527551的博客 157

hdu 4155

http://acm.hdu.edu.cn/showproblem.php?pid=4155 搜索博弈 #include #include #include using namespace std; int card[8]; char s[30];   int dfs(int sum)  // 用来判断判断当前局面即和为sum是否为胜局 {

态度决定高度 541

【dfs博弈HDU 4155

一开始理解错题意,以为每个人各自有一堆,后来发现是总共才有1堆,问谁会使得堆的和大于31就是输,可以看出31是必胜点,每个人最优的策略是使得自己到达31,因此可以dfs,利用回溯把每个状态输赢求出来,类似于dp,从后往上推。状态的话可以用一个七维数组记录 char str[200]; int dp[33][5][5][5][5][5][5]; int num[10]; int lin(int

leolin_的专栏 731

【dfs】HDU 4155

dfs。只标记空格 int g[22][22]; bool vis[22][22]; int d[4][2] = {0,1,0,-1,1,0,-1,0}; int n; int sumb,sumw,sum; int tag; void dfs(int x,int y){ int i,j; for(i=0;i<4;i++){ int xx = x+d[i][0];

leolin_的专栏 778

HDU 4155 (博弈 记忆化搜索)

题目链接:点击这里题意:有1,2,3,4,5,6各四张牌,AB轮流出牌,谁先使得总和超过31就输.告诉你已经出牌的序列,求最优策略下谁赢.经典的博弈题了.先把游戏结束的状态挖出来,然后记忆化搜索一遍即可.#include <bits/stdc++.h> #define Clear(x,y) memset (x,y,sizeof(x)) #define FOR(a,b,c) for (int a =

morejarphone~ 523

1470. The Game Of Take Numbers

题目链接这道题属于

spring_translate的博客 446
上一篇: POJ 3694 Network (tarjan bcc + LCA)
下一篇: HDU 1536 S-Nim(组合游戏Nim)
TaoSama
博客等级 码龄15年 89粉丝 457原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值