hdu6188 Duizi and Shunzi(贪心)

融合SAM提示引擎的交互式医学图像分割:U-Net架构升级与实战 语义分割是计算机视觉的核心任务,旨在为图像中的每个像素分配类别标签,其原理是通过编码器-解码器结构学习像素级特征表示。在医学影像分析领域,精准的分割技术对于辅助诊断具有关键价值,尤其在消化道内镜图像的息肉与肿瘤检测中,分割精度直接影响临床决策的可靠性。传统全自动分割模型如U-Net虽广泛应用,但在面对复杂多变的临床图像时,其缺乏与医生交互的能力,难以融入领域知识进行即时修正。为此,将Meta AI发布的Segment Anything Model(SAM)的交互式提示能力与经典U-Net架构相结合,构建人机 阅读详情

思路来源

https://blog.csdn.net/qq_37497322/article/details/77851437

题意

有若干张牌,三个连续数字组成一个顺子,两个相同数字组成一个对,

求最大的顺字数+对数。

题解

从最大到最小遍历,能用两个相同的构成对就构成对,

如果a[v]最后还剩一张,说明这张要被弃掉了;

再去看a[v-1]是不是奇数张,是的话说明也有一张要被弃掉;

如果出现这种情况,就用一张a[v-2]来救这两张废弃牌。

这样,我们就用一张非废弃牌凑齐了一个贡献,

而常规操作下,一个顺需要三张非废弃牌,一个对需要两张废弃牌,显然是更优的。

心得

贪心真的好迷啊……

自己之前想了一个伪算法,先凑顺,再凑对,

最后把个数大于等于2的顺,如1 2 3 1 2 3这种还原回三个对,

然而WA了。

不过现在想想,1 1 2 2 3直接就能ban掉该伪算法。

还是太菜了……

代码

#include <iostream>
#include <algorithm> 
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <bitset> 
const int INF=0x3f3f3f3f;
const int maxn=1e6+5;
const int mod=1e9+7;
const double eps=1e-7;
typedef long long ll;
#define vi vector<int> 
#define si set<int>
#define pii pair<int,int> 
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define lowbit(x) (x&(-x))
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sclf(x) scanf("%lf",&(x))
#define pri(x) printf("%d",(x))
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define per(i,j,k) for(int i=j;i>=k;--i)
#define mem(a,b) memset(a,b,sizeof(a)) 
using namespace std;
int n,a[maxn],top,ans;
int main()
{
	while(~scanf("%d",&n))
	{
		mem(a,0);top=0;ans=0;
		rep(i,0,n-1)
		{
			int v;
			sci(v);
			a[v]++;
			top=max(top,v);
		}
		per(j,top,1)
		{
			ans+=a[j]/2;
			a[j]%=2;
			if(j>=3&&(a[j]%2)&&(a[j-1]%2)&&a[j-2])ans++,a[j]=0,a[j-1]--,a[j-2]--;
		}
		printf("%d\n",ans);
	}
	return 0;
}

 

【突变检验方法一】MATLAB实现Pettitt突变检验 MATLAB实现Pettitt突变检验及贝叶斯突变检测等 阅读详情

相关推荐

导数在工程与AI中的12个实战应用解析

导数作为数学中的基本概念,本质是描述变化率的工具,其核心价值在于将非线性问题局部线性化处理。从原理上看,通过极限过程捕捉函数瞬时变化特性,使工程师能精确控制系统动态行为,帮助科学家量化自然规律变化速率。在技术实现层面,现代符号计算(如Mathematica)、数值计算(如MATLAB)和自动微分(如PyTorch)工具链的发展,大幅提升了导数计算的效率与精度。典型应用场景涵盖机械控制(如ABS防抱死系统)、金融工程(如期权希腊值计算)、医疗影像(如Canny边缘检测)等领域。特别在机器学习中,反向传播算法依

weixin_35509395的博客 324

Hihocoder 1356 分隔相同整数 (贪心)

题目链接:http://hihocoder.com/problemset/problem/1356 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个包含N个整数的数组A。你的任务是将A重新排列,使得任意两个相等的整数在数组中都不相邻。   如果存在多个重排后的数组满足条件,输出字典序最小的数组。   这

kalilili的专栏 835

用C#完成最小二乘法拟合平面方程,再计算点到面的距离

【代码】用C#完成最小二乘法拟合平面方程,再计算点到面的距离。

MechMaster 650

HDU 1735 统计数字(贪心)

题意:告诉你,n行,l 列,m段 找出最少被涂掉的字的个数 题解:记录总共0的个数,减掉m*2 ,在两个0开头的上一行尾数 0的个数记下来,排个序,减掉越长的越好,一共减掉m-1个就可以了。 #include #include #include #include #include using namespace std; int mp[10005][105]; int b[1000

DouBoomFly的博客 615

OpenCV2.4.9+vs2012配置

下载OpenCV2.4.9。 下载地址:http://opencv.org/downloads.html2.下载后,解压。 请记住解压路径,后面根据自己的解压路径进行配置。我的路径是E:\ 3.配置环境变量 win7系统:(计算机-属性-高级系统设置-高级-环境变量) 1)编辑系统变量Path:添加E:\opencv\build\x86\vc11\bin; 2)添加/编辑用户变量P

sybil_w的博客 974

HHD Device Monitoring Studio:破解版在串口调试中的实战应用

本文详细介绍了HHD Device Monitoring Studio破解版在串口调试中的实战应用,包括安装指南、串口监控功能解析、Modbus RTU协议分析案例以及自定义协议解析技巧。通过具体操作步骤和性能优化建议,帮助开发者高效完成端口监控和调试任务,提升工作效率。

weixin_29268331的博客 976

HDU 6188 Duizi and Shunzi(贪心)

Nike likes playing cards and makes a problem of it. Now give you n integers, ai(1≤i≤n)ai(1≤i≤n) We define two identical numbers (eg: 2,22,2) a Duizi, and three consecutive positive integers (eg: 2,3,42,3,4) a Shunzi. Now you want to use these intege

HJY 1017

基于ADPSS的直驱风电单机模型建模指南:跟网型与构网型

本文介绍了基于ADPSS平台的直驱风电单机建模方法,包含跟网型和构网型两种控制策略。模型采用模块化设计,共享风力机与桨距角控制部分,通过FORTRAN语言实现自定义建模。跟网型采用锁相环同步和矢量控制,构网型则采用虚拟同步机技术模拟同步发电机特性。详细阐述了风力机气动模型、桨距角控制算法及代码实现,为新能源并网仿真提供了实用参考。全文约150字,涵盖模型架构、数学方程和ADPSS实现要点。

huanghm88的专栏 179

HDU 6188 Duizi and Shunzi 贪心

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 题意:给了n个数,然后现在问我们最多构成多少个对子和顺子,其中对子是2个相同的牌,顺子是3个连续的牌。 解法:考虑贪心,我们尽量放对子,但是有一种特殊情况就是,我们可以退一个对子出来和周围的相邻点构成顺子。 #include <bits/stdc++.h> us...

aishangg437965的博客 137

芒果YOLOv8改进72:动态标签分配策略篇之ATSS:自适应训练样本选择Adaptive Training Sample Selection策略

YOLOv8代码实践|ATSS标签分配策略改进🥭

包括YOLOv5、YOLOv7、YOLOv8等模型改进 2914

2026华为OD机试真题 9月27日 新系统 【均衡调度】

华为OD机试真题 新系统 9月27号【均衡调度】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题 【均衡调度】多语言题解。

qq_45776114的博客 1791

Duizi and Shunzi HDU - 6188 贪心

Nike likes playing cards and makes a problem of it. Now give you n integers,ai(1≤i≤n)ai(1≤i≤n) We define two identical numbers (eg:2,22,2) a Duizi, and three consecutive positive integers (eg:2,...

Focus5679的博客 190

【C语言】自定义类型 —— 结构体

结构体全方面讲解

StackFrame 1611

HDU6188 Duizi and Shunzi【贪心】

  Duizi and Shunzi   Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2266    Accepted Submission(s): 895     Problem Description Nike li...

海岛Blog 1037

深度学习工具包 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")

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

HDU6188-Duizi and Shunzi【贪心】

Nike likes playing cards and makes a problem of it. Now give you n integers,ai(1≤i≤n)ai(1≤i≤n) We define two identical numbers (eg:2,22,2) a Duizi, and three consecutive positive integers (eg:2,...

独钓门前月 394

【贪心】hdu - 6188 Duizi and Shunzi

Problem Description 输入一个n,接下来有n个数,让你求出能组成最多的对子或者顺子的和。 对子: (2,2),顺子: (1,2,3)。 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188思路: 从小跑到大。例如1,1,2,3。跑到1的时候有对子,这时候优先要对子。不然你牺牲对子去换顺子,也就是一比一,根本不会赚。例如

ACMer 梁剑锋 的博客 1289

【2017广西邀请赛】hdu 6188 Duizi and Shunzi 贪心

Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai(1≤i≤n) We define two identical numbers (eg: 2,2) a Duizi, and three consecutive positive

弱菜zc 607

HDU - 6188 Duizi and Shunzi (贪心)

题目链接https://vjudge.net/problem/HDU-6188 题目 Nike likes playing cards and makes a problem of it. Now give you n integers,ai(1≤i≤n)ai(1≤i≤n) We define two identical numbers (eg:2,22,2) a Duizi, a...

Viator 183

HDU-6188 Duizi and Shunzi 贪心

题目题意 给你n个数,两个相同的数可以凑成一个对子 三个连续的数可以凑成顺子,顺子和对子的价值都是1 问你能凑出的最大价值。解题思路 : 考虑凑出最大价值,一开始可以往贪心上去想。 一开始最容易想到,对子的单位花费肯定小于顺子的花费,那么尽可能多的凑出对子,剩下的再去凑顺子,这样得到的价值应该是最大的。 然而这样是错的。 如果一个对子拆开能凑出两个顺子,那么这样贪心就不是最优的了。 之后又想到

lifelike 333

HDU 6188 - Duizi and Shunzi ( 贪心 )

题意 给出n张牌, 每张牌编号为ai, 有两种组成方式, 一种叫”对子”, 也就是两张牌牌面相同, 另一种叫”顺子”, 也就是三张牌牌面连续, 每张牌最多只能用一次, 求最多能组成多少组 思路 贪心 贪心方法 : 枚举每张牌面的数量, 先尽可能多的组成对子, 那么至多只能剩下一张, 若该牌面只剩一张, 就要想办法将其与后面的牌组...

a7152326的博客 110

HDU6188 Duizi and Shunzi 贪心

Duizi and ShunziTime Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2015    Accepted Submission(s): 807Problem Description Nike likes playing cards ...

紫芝的博客 539

(HDU) 6188 G - Duizi and Shunzi (贪心)

传送门 题意:给你一串序列,两个一样的是对子,连续的三个是顺子,求顺子个数和对子个数的最大值。 思路:从小到大贪心,先看自己能组成的对子有多少个,如果最后还余了1,那就考虑顺子,假设当前数为x,但这里的条件是num[x+1]%2==1 && num[x+2] ,就是能不用后面的就不用后面的,因为后面的数可能还会对后面的组合造成贡献。 #include<bits/st...

一只不争气的蒸汽机的博客 313

HDU-6188-Duizi and Shunzi(贪心)

Duizi and Shunzi Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai(1≤i≤n) We define two identical numbers (eg: 2,2) a Duizi, and three consecutive pos...

qq_43461168的博客 161

2017广西邀请赛/hdu - 6188 Duizi and Shunzi(贪心)

Duizi and Shunzi Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 245    Accepted Submission(s): 115 Problem Description Nike likes

The_star_is_at的博客 885

HDU 6188 Duizi and Shunzi 贪心 思维

  题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188   题目描述: 就是一副扑克牌, 可以打顺子, 可以打对子, 问怎样顺子和对子的总数能够最多   解题思路: 贪心, 对于一种牌先向前找看看是否能够组成顺子, 如果能组成顺子就出顺子, 然后就将本身剩余的全部当做对子, 在这里我们需要对前两个进行预处理, 将对子全部拿走, 所以前两个只...

weixin_33958585的博客 121
上一篇: poj3040 Allowance (贪心☆☆☆☆☆)
下一篇: Codeforces Round #437 Div. 2 C. Ordering Pizza (贪心经典)
小衣同学
博客等级 码龄9年 1444粉丝 995原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小衣同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址