uva 131 - The Psychic Poker Player

基于PINN的一个简单的求解偏微分方程实例 本人是做化工模拟的一名学生,最近在学习PINN(Physics-Informed Neural Networks,物理信息神经网络)对管道动力学进行建模研究,PINN由于其对机理与数据的良好兼顾性非常热门,本文是作者对PINN入门研究过程的一个练手小题目,main code也是作者代码是基于pytorch2.6.0写的,发上来供各位参考,欢迎研究管道动力学和PINN的小伙伴一起讨论~ 阅读详情

参考题解  原题  子集生成的问题。用增量构造法。需要先弄清楚规则。特殊的顺子有两种,TJQKA和A2345。


#include<cstdio>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=15;
char *sf="A23456789TJQK";
char *su="CDHS";

char str[9][20]={"straight-flush","four-of-a-kind","full-house","flush","straight","three-of-a-kind",
"two-pairs","one-pair","highest-card"};

int A[8],ans,face[maxn],suit[maxn][5];
char s[maxn][5];

int search(int cur)
{
	memset(face,0,sizeof(face));
	memset(suit,0,sizeof(suit));
	int i,j,k,f,first,m,n;
	//printf("cur=%d\n",cur);
	for(i=0;i<5-cur;i++)
	  A[cur+i]=5+i;
	for(i=0;i<5;i++)
	{
		m=strchr(sf,s[A[i]][0])-sf;
		n=strchr(su,s[A[i]][1])-su;
		face[m]++;
		suit[m][n]++;
	}
    for(first=0;!face[first];first++);
    
    for(i=first;i<13;i++)
        if(face[i])
        {
            for(j=i,n=0;j<13&&face[j];j++)
                n++;
            if(n==5||(n==4&&j==13&&face[0]))
            {
                for(k=0;k<4;k++)
                    if(suit[first][k])
                        break;
                for(f=first+1;f<13;f++)
                    if(face[f]&&suit[f][k]!=suit[first][k])
                        break;
                if(f==13)
                    return 0;
            }
        }
        
    for(i=first;i<13;i++)
        if(face[i]==4)
            return 1;
            
    for(i=first;i<13;i++)
        if(face[i]==3)
        {
            for(j=first;j<13;j++)
                if(face[j]==2)
                    return 2;
            break;
        }
    
    for(k=0;k<4;k++)
    {
        for(i=first;i<13;i++)
            if(face[i]>1||(face[i]&&!suit[i][k]))
                break;
        if(i==13)
            return 3;
    }
    
    for(i=first;i<13;i++)
        if(face[i])
        {
            for(n=0,j=i;j<13&&face[j];j++)
                n++;
            if(n==5||(n==4&&j==13&&face[0]))
                return 4;
        }
    
    for(i=first;i<13;i++)
        if(face[i]==3)
            return 5;
    
    for(i=first;i<13;i++)
        if(face[i]==2)
            for(j=i+1;j<13;j++)
                if(face[j]==2)
                    return 6;
            
    
    for(i=first;i<13;i++)
        if(face[i]==2)
            return 7;
            
    return 8;
}

void try_subset(int cur)
{
	if(cur<=5)
	{
		//for(int i=0;i<cur;i++) printf("%d ",A[i]);
	    //printf("\n");
		int k=search(cur);
		if(k<ans) ans=k;
	}
	int s=cur? A[cur-1]+1:0;
	for(int i=s;i<5;i++)
	{
		A[cur]=i;
		try_subset(cur+1);
	}
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("131.txt","r",stdin);
#endif
	int i;
	while(scanf("%s",s[0])==1)
	{
		for(i=1;i<10;i++)  scanf("%s",s[i]);
		printf("Hand:");
		for(i=0;i<5;i++)  printf(" %s",s[i]);
		printf(" Deck:");
		for(i=5;i<10;i++) printf(" %s",s[i]);
		printf(" Best hand: ");
		ans=8;
		try_subset(0);
		//printf("%s",str[t++]);
		printf("%s\n",str[ans]);
	}
    return 0;
}



【网络安全 | 渗透工具】Hydra安装使用详细教程 Hydra,也称九头蛇,是一款非常强大的暴力破解工具(密码能否被破解关键在于字典是否足够强大),支持多种服务协议的账号和密码进行爆破,包括Web登录、数据库、SSH、FTP等服务,支持Linux、Windows、Mac平台安装。该工具支持以下协议的爆破:Hydra在kali中自带,这里介绍windows下的安装方法。zip下载地址:https://gitcode.com/maaaaz/thc-hydra-windows/tree/master下载完成后解压: 再将thc-hydra-windows-mast 阅读详情

相关推荐

WinForm多语言切换实战:5分钟搞定中英文界面(附完整代码)

本文提供了WinForm应用实现中英文界面切换的两种高效实战方案。通过利用内置的本地化机制和资源文件,开发者可以在5分钟内为窗体添加多语言支持,并附有完整代码示例,帮助快速应对软件国际化需求。

weixin_29230773的博客 414

UVa 131 The Psychic Poker Player

本文介绍了一个扑克牌游戏问题,玩家初始获得5张手牌,可通过丢弃0-5张牌并用牌堆顶部的牌替换来优化牌型。题目假设玩家能预知牌堆顶部的5张牌。解题思路是枚举所有可能的换牌方案(共32种),并对每种方案评估牌型价值。关键点包括:换牌规则、枚举策略(暴力搜索)、牌型判断顺序(从同花顺到高牌共9种)。代码实现通过回溯法生成所有换牌组合,调用牌型判断函数确定最优解。该算法能高效找到最佳换牌策略,使最终手牌价值最大化。

寂静山林 690

MT9V034摄像头学习笔记(一)_mt9v034摄像头循迹代码(1)

函数名称:uint8_t SCB_RegRead(uint8_t Device,uint8_t Address,uint16_t *Data)* 函数名称:uint8_t SCB_RegWrite(uint8 Device,uint8 Address,uint16 Data)* 函数名称:uint8 SCCB_SendByte(uint8 Data)* 函数名称:uint8 SCCB_ReadByte(void)* 修改时间:2018年3月4日。* 修改时间:2018年3月4日。

2401_87555661的博客 910

uva-131 - The Psychic Poker Player

The Psychic Poker Player  In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards and ha

写东西的地方 797

深入解析AutoConfigURL劫持:从注册表权限到一键修复

本文深入解析了AutoConfigURL劫持的原理,揭示其通过篡改注册表权限锁定浏览器设置的机制。文章提供了从手动修复注册表权限到使用一键修复工具的详细解决方案,并指导用户进行DNS检查与病毒查杀,以彻底根除此类顽固劫持问题。

weixin_29229989的博客 782

在 CentOS Stream 10 上搭建 Kubernetes 集群并支持开发调试与日志查看

搭建 Kubernetes 集群的每个步骤详细的文档。

灵犀物润 1650

uva 131 The Psychic Poker Player

思路挺简单的,就是判断手牌的类型比较麻烦一点,核心思想是枚举手牌子集,然后把桌上的牌的上面的某几张牌和手牌子集中的牌凑足5张,所有的情况里面最优的组合就是最后的答案,注意子集为空集的时候的特殊情况。 #include #include #include struct node { int value; char color; }; bool operator > (struct

皓首不倦 不负少年 744

ColorOS13系统账户锁与密码锁破解全指南:从恢复模式到激活绕过

本文针对ColorOS13系统用户,详细解析了忘记锁屏密码(数字/图案锁)和遭遇OPPO账户锁(激活锁)的合法解决方案。核心是通过官方恢复模式进行格式化操作清除锁屏密码,并强调账户锁需通过密码找回或官方售后等正规途径解除。文章旨在帮助设备合法所有者恢复使用权,并提供了安全操作指南与数据备份建议。

weixin_28304023的博客 981

UVA 131 The Psychic Poker Player

UVA 131 The Psychic Poker Player题目大意:手牌五张 排堆五张,超能力者可以看到这10张牌,可以弃掉x张牌摸x张牌,问能凑出的最大的牌 比较规则 比较规则如下:(按优先级排序)1.straight-flush:同花顺,牌面为T(10) - A2.four-of-a-kind:四条,牌面有4个相同的值;3.full-house:牌面有3个相同值,剩下2个也相同值;4.

ZeroLH00的博客 436

华为OD面试八股真题 - 操作系统相关 - 2

华为OD技术面,操作系统相关八股真题提供详细解答,这篇博客主要涉及于进程和线程相关知识点

qq_45776114的博客 987

PCIe协议之 Equalization篇 之 理论篇 之 FFE

作为最后一道“精加工”工序,DFE利用其不放大噪声的优势,精准地消除残余的、强烈的后光标ISI,最终得到一个非常干净、张得很开的眼图,供判决器使用。信号经过信道衰减后变得模糊,首先由CTLE进行“粗调”,提供一个宽频带的增益,将眼图初步打开,为后面的DFE创造一个可以正常工作的信号环境。,它通过将输入信号在不同时间点上的多个副本(称为“抽头”)进行加权求和,来直接塑造或“整形”输出信号的波形。:这是最主要的信号路径,通常系数为正值,决定了信号的幅度。:将所有加权后的信号相加,产生最终的均衡输出。

那么菜的博客 766

UVa 131 - The Psychic Poker Player

一手牌(规则请见:http://dpk888.com/school/discussions/%E4%B8%80%E6%89%8B%E7%89%8C%E7%9A%84%E7%89%8C%E5%9E%8B-poker-hands#per_page=10),枚举 + 模拟,关键是明白其桌子上的牌相当于一个栈,只有丢掉手里相应数量的牌才可以从栈中依次抽出相应数量的牌来维持手里始终有五张牌,依此枚举。

GooMaple 725

ximalaya 新xm-sign逆向思路

本文主要介绍目标网站新xm-sign值的逆向思路。仅代表个人理解,如有其他建议可在评论区沟通。声明仅仅记录一下自己的学习方法,不作为其他参考、更不作为商业用途。如有侵犯请联系本人删除。

weixin_66580433的博客 2022

UVA131 HDU1629 The Psychic Poker Player【暴力】

The Psychic Poker Player Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 255 Accepted Submission(s): 49 Problem Description In 5-card draw p...

海岛Blog 725

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

UVA 131 The Psychic Poker Player

UVA-131题意:给出 5 张手牌和 5 张备用牌。可以任意丢弃手上的 k 张牌,并从备用牌上方抽 k 张补充。求手上能达到的最大牌面。 解题思路: 首先要搞清楚牌面的大小顺序。 同花顺(AKQJ10,花色相同就行)>四条(四张相同的牌,炸弹 = =) > 福尔豪斯 (aaabb的牌型) > 同花(5张花色相同) > 顺子 (连续,无视花色。A可以当1也可以当14)> 三条 (aaabc

QzNarsh的博客 625

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

UVA 131 - The Psychic Poker Player 暴力不解释

#include #include #include using namespace std; char t[][20] = {"straight-flush","four-of-a-kind","full-house","flush","straight" ,"three-of-a-kind","two-pairs","one-pair","highest-ca

泪无痕 741

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

uva 131 The Psychic Poker Player(直接枚举)

The Psychic Poker Player  In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards an

不慌不忙、不急不躁 1833

uva131 The Psychic Poker Player

The Psychic Poker Player Time Limit: 3000MS     64bit IO Format: %lld & %llu Description In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at)

keshuqi的博客 553

[枚举]The Psychic Poker Player UVA131

The Psychic Poker Player  In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards and

九问的烦恼 1704

uva 131 -The Psychic Poker Player(德州扑克)

G - The Psychic Poker Player Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Appoint description:  System Crawler  (2013-05-30) Description

NiaNiaJR的专栏 1667

uva 10557 - XYZZY 关键词:正环,无敌bfs,单源最短路spfa算法

笔者用时:4h。方法一:当发现有个和为正值的环存在时,直接求看该点能否直接到达终点。如果可以,直接返回true,即winnable。否则,不用做任何的标记。因为不会再去探索它是否可以直接到达终点。这个方法效率很高。rank:7。在搜索的过程中看看有没有正环,没有正环则继续搜索,当发现所有路径都不能到达终点时,返回假值。 方法二:要低效一点。rank:300左右。用的spfa。 用最后一组给的样

LeanCloud-lzwjava 3389
上一篇: uva 10098 - Generating Fast
下一篇: 埃及分数
lzw_java
博客等级 码龄15年 49粉丝 73原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值