HDU 5228-ZCC loves straight flush

本文介绍了一个扑克牌游戏算法,目标是在德州扑克中通过最少的牌面更改实现同花顺。文章详细解释了如何通过枚举策略来寻找最优解,并提供了一段C++代码示例。

Description

After losing all his chips when playing Texas Hold'em with Fsygd on the way to ZJOI2015, ZCC has just learned a black technology. Now ZCC is able to change all cards as he wants during the game. ZCC wants to get a Straight Flush by changing as few cards as possible. 

We call a five-card hand a Straight Flush when all five cards are consecutive and of the same suit. You are given a five-card hand. Please tell ZCC how many cards must be changed so as to get a Straight Flush. 
   
Cards are represented by a letter('A', 'B', 'C', 'D') which denotes the suit and a number('1', '2', $\cdots$, '13') which denotes the rank. 
   
Note that number '1' represents ace which is the largest actually. "1 2 3 4 5" and "10 11 12 13 1" are both considered to be consecutive while "11 12 13 1 2" is not.
 

Input

First line contains a single integer $T(T=1000)$ which denotes the number of test cases. 
For each test case, there are five short strings which denote the cards in a single line. It's guaranteed that all five cards are different.
 

Output

For each test case, output a single line which is the answer.
 

Sample Input

3 A1 A2 A3 A4 A5 A1 A2 A3 A4 C5 A9 A10 C11 C12 C13
 

Sample Output

0 1 2

暴力枚举 分四个数组 一旦有ABCD相应牌就扫一下该数组 更新MAX

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
#define INF 0x3f3f3f3f

int MAX,cnt;
void CNT(int a[])//对于数组从第一个元素开始每五个扫一下 看五个需要换多少张 扫到结束 如a[1-5] a[2-6] 比较更新MAX
{
    for(int i=1; i<=10; i++)
    {
        cnt=0;
        for(int j=i; j<i+5; j++)
        {
            if(a[j]==0) cnt++;
        }
        if(cnt<MAX) MAX=cnt;
    }
}
int main()
{
    int a,T;
    char c;
    scanf("%d",&T);
    while(T--)
    {
        int A[30]= {0},B[30]= {0},C[30]= {0},D[30]= {0};
        int aa=0,bb=0,cc=0,dd=0;
        for(int i=0; i<5; i++)
        {
            cin>>c>>a;
            getchar();
            if(c=='A')
            {
                A[a]=A[a+13]=1;
                aa=1;
            }
            else if(c=='B')
            {
                B[a]=B[a+13]=1;
                bb=1;
            }
            else if(c=='C')
            {
                C[a]=C[a+13]=1;
                cc=1;
            }
            else
            {
                D[a]=D[a+13]=1;
                dd=1;
            }
        }
        MAX=4;
        if(aa==1) CNT(A);
        if(bb==1) CNT(B);
        if(cc==1) CNT(C);
        if(dd==1) CNT(D);
        printf("%d\n",MAX);
    }
    return 0;
}


内容概要:本文介绍了一种用于电磁暂态(EMT)研究的第四类全变流器型风力发电系统的通用Simulink仿真模型,旨在构建一个能够准确反映实际风电系统动态特性的简化通用模型。该模型涵盖了风力机、传动链、发电机、全功率变流器及其控制策略等关键组成部分,重点突出系统在电网故障、风速波动等复杂工况下的动态响应能力,适用于风电并网电磁暂态分析、新型电力系统稳定性评估及高比例可再生能源接入场景的研究。模型设计兼顾准确性与仿真效率,便于研究人员快速搭建和调试,推动风电系统建模与控制技术的发展; 适合人群:具备一定电力系统理论基础和MATLAB/Simulink仿真能力,从事新能源发电、电力电子变换、风电并网控制及相关方向的研究生、科研人员及工程技术人员; 使用场景及目标:①开展风电系统在电网扰动下的电磁暂态仿真分析;②研究全功率变流器风电机组的动态行为与控制特性;③支撑新型电力系统中高渗透率风电接入的稳定性与电能质量评估,服务于学术研究、课程教学与工程项目前期仿真验证; 阅读建议:建议读者结合文中提供的模型结构与参数设置,在Simulink环境中动手复现并调试仿真模型,通过设置不同运行工况(如三相短路、低电压穿越、风速突变等)观察系统响应,深入理解全变流器风电机组的建模方法、控制逻辑与动态特性,进而拓展应用于更复杂的多机并网或综合能源系统仿真场景。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值