hdu 1133 Buy the Ticket(卡特兰数)

手把手教你构建轻量级CLIP模型:从理论到实践 本文手把手教你从零构建一个轻量级CLIP模型,深入解析其核心原理——对比学习,并提供完整的代码实践。通过精简的模型架构、数据准备和训练循环实现,帮助读者彻底理解多模态模型如何让图像与文本在共享空间中对齐,为学习更复杂的AI模型打下坚实基础。 阅读详情

Buy the Ticket

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1133

解题思路:

首先假设人无区别

令f(m,n)表示有m个人手持¥50的钞票,n个人手持¥100的钞票时共有的方案总数。则可以分以下情况讨论这个问题:

(1)当n=0时

     N=0意味着排队购票的所有人手中拿的都是 ¥50的钞票,那么这m个人排队方案总数为1。

(2)当m<n时

    显然,f(m,n)=0

(3)其他情况:
    考虑(m+n)个人排队购票的情景,第(m+n)人站在第(m+n-1)个人的后面,则第(m+n )个人的排队方式可以由下列两种

情况获得:

a.第(m+n )个人手持¥100的钞票,则在他之前的(m+(n-1))个人中有m个人手持¥50的钞票,有(n-1)个人手持¥100的钞

票,此种情况共有f(m,n-1);

b.第(m+n )个人手持¥50的钞票,则在他之前的((m-1)+n)个人中有m-1个人手持¥50的钞票,有n个人手持¥100的钞票,此

种情况共有f(m-1,n);

递推公式—— 

根据加法原理得到:

f(m,n)=f(m-1,n)+f(m,n-1)

于是得到f(m,n)的计算公式


计算示意图:

                                

所以:对于一般情况(m>=n>0)
可以推出下面直接的公式: 
f(m,n)= C(m+n,n)-C(m+n,m+1)

AC代码:

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        int t = 1;
        while(sca.hasNext()){
            int m = sca.nextInt();
            int n = sca.nextInt();
            if(m+n == 0)
                break;
            BigInteger sum;
            if(m < n)
                sum = BigInteger.ZERO;
            else{
                sum = BigInteger.ONE;
                for(int i = 1; i <= m+n; i++)
                    sum = sum.multiply(BigInteger.valueOf(i));
                sum = sum.multiply(BigInteger.valueOf(m-n+1));
                sum = sum.divide(BigInteger.valueOf(m+1));
            }
            System.out.println("Test #"+t+":");
            System.out.println(sum);
            t++;
        }
    }
}


接入穿山甲SDK时,Unity打Android包报错日志 SDK工程设置为Enable,项目工程设置为Disable。2、将unitypackage导入包名为:com.DefaultCompany.Myproject的另一个工程,打包报错。3、点击工程默认弹出Enable Android Auto-resolution 设置选项,点击Enable。1、新建一个空工程,设置包名为:com.ceshi.hewen,正常打包无报错,导出unitypackage。2、点击Reset to Defaults 重置参数,再点击ok关闭设置窗口。 阅读详情

相关推荐

bq34z100-G1电池计量芯片调试全攻略:从硬件设计到算法学习

电池电量计量是嵌入式系统与电源管理中的关键技术,它通过实时监测电池的电压、电流和温度,结合库仑计与阻抗跟踪等算法,实现对剩余电量的精确估算。这项技术的核心价值在于提升用户体验与设备可靠性,确保系统能在电量不足时及时预警或采取保护措施,广泛应用于消费电子、电动工具和储能系统等领域。在工程实践中,TI的bq34z100-G1芯片因其高集成度和强大的阻抗跟踪算法而备受青睐,但其调试过程涉及复杂的硬件设计验证、参数校准与学习周期配置。本文将聚焦于使用串口调试助手进行数据交互与验证,并详细拆解如何通过系统的学习流程让

weixin_34342905的博客 472

[hdu1133]Buy the Ticket(dp)

题目描述传送门 题意:每张门票卖50元。现在有n个拿50元的人和m个拿100元的人(认为每个人是不同的)排队买票,售票处起初并没有零钱可以找。问有多少种排队方案使所有的人都可以顺利买到票。题解我记得这道题在很久很久以前是Loli某一次奇怪的模拟赛。。。然而当时并不会。。。现在把它重新翻出来a掉感觉很开心。 其实就是要保证无论何时第一种人的前缀和一定比第二种人多。我们把这两种人用0/1来表示。

zyf2000 663

超简单的视频换脸,效果相当不错!完全白嫖的技术,来自ComfyUI 官方客户端一键搞定!手把手教会你如何下载安装部署,而且教你如何使用。

如果你电脑上没有安装Visual Studio的C++桌面开发组件,还有Windows应用SDK C++模板,那么你需要自行去下载安装下【安装后默认界面会自动识别系统语言,当然如果你是中文繁体用户,那么你可以在 ComfyUI 的管理器里下载。】并把它放入根目录-models-insightface文件夹内 , 同时下载视频换脸工作流 【分享手把手教你视频换脸,本地部署,轻轻松松当上“电影主角”】,否则insightface无法被正常载入。) 这是换脸必备的工具 ,安装后重启;

TianLeung的博客 3005

hdu 1133 Buy the Ticket

Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2898    Accepted Submission(s): 1214 Problem Description The "Harry

shiyuan的专栏 1247

在Ubuntu 22.04上从零搭建FVCOM环境:手把手搞定Linux、Intel编译器与NetCDF库

本文详细指导在Ubuntu 22.04上从零搭建FVCOM环境,涵盖Linux系统配置、Intel编译器安装、NetCDF库编译及常见问题解决。通过手把手教程,帮助科研人员高效完成水动力数值模拟环境的部署,特别适合水环境研究领域的初学者。

weixin_30613727的博客 658

【QGIS】PyCharm集成pyqgis的processing工具箱:环境配置与初始化实战

本文详细介绍了如何在PyCharm中配置QGIS的Python环境并成功集成其强大的Processing工具箱。文章核心解决了独立环境下导入processing模块失败、算法无法调用等常见难题,通过手动添加插件路径和执行关键初始化步骤,实现了在PyCharm中丝滑调用QGIS地理处理算法,从而将复杂的空间分析流程自动化。

weixin_28831399的博客 404

HDU-1133Buy the Ticket 卡特兰数买票问题

题目:HDU-1133 Buy the Ticket     题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1133     题目: Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T

桐小目的秘密基地 2557

别再为模糊的3D重建头疼了!手把手教你用3DSlicer处理DICOM数据,搞定医学影像三维可视化

本文详细解析了医学影像三维重建中常见的模糊问题,并手把手教你使用3DSlicer处理DICOM数据,实现精准的三维可视化。从层厚设置到数据格式转换,再到重建算法选择和渲染参数微调,提供了一套完整的优化方案,特别适合临床医生和医学影像处理人员提升工作效率。

weixin_28693447的博客 264

HDU Buy the Ticket

Problem Description The \\\\\\\"Harry Potter and the Goblet of Fire\\\\\\\" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, w

lin810921141的专栏 755

基于知识图谱的档案智慧问答系统:构建智能化档案管理与知识服务新范式

基于知识图谱的档案智慧问答系统是档案管理领域的一次重要创新,它通过将档案数据转化为结构化的知识图谱,并结合自然语言处理和智能问答技术,实现了档案信息的智能化管理与服务。该系统不仅能够提升档案管理的效率,还能为用户提供更全面、更便捷的知识服务,具有广泛的应用前景和深远的社会意义。未来,随着技术的不断进步和应用场景的不断扩展,基于知识图谱的档案智慧问答系统将在更多领域发挥其价值,为档案管理领域的智能化转型提供强有力的支持。

qq_62634009的博客 1590

Modbus协议学习第一篇之基础概念

因工作需要而接触Modbus,正在恶补知识,利用博客的方式来加深理解和记忆,同时希望同行大佬能一起交流。

hzf978742221的博客 886

Hdu1133 Buy the Ticket 大数+递推

Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won’t you?

Megumin的博客 437

[Dify实战] 项目复盘助手:自动拉数据、生成复盘报告

本文介绍如何利用Dify平台构建自动化项目复盘助手,解决传统人工复盘效率低、易遗漏等问题。系统通过自动拉取Git/Jira等数据源,计算关键指标后,由LLM生成结构化复盘报告。文章详细讲解了数据采集、指标计算、Prompt设计等核心模块的实现,并分享了完整Workflow搭建步骤。实践表明,该系统能将复盘耗时从4小时缩短至10分钟,显著提升数据准确率和执行频率。最后总结了数据一致性、输出质量等常见问题的解决方案,强调Dify+LLM组合可实现复盘流程的自动化流水线。

技术小甜甜:传播可落地技术,帮助个人和企业降低解决真实场景问题的成本 127

Hdu 1133 Buy the Ticket[卡特兰数小变形]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1133 题目意思,n个人拿50元,m个人

1212

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

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

HDU - 1133 Buy the Ticket 【大数】【卡特兰数】【Java】

Description The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won’t you? Suppose the...

一定要站在自己热爱的生活里闪闪发光 3万+

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU 1133 Buy the Ticket【卡特兰数】

Buy the Ticket Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 11   Accepted Submission(s) : 3 Font: Times New Roman | Verdana | Georgia

Puya的博客 473

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

HDU1133 Buy the Ticket —— 卡特兰数

题目链接:https://vjudge.net/problem/HDU-1133 Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7427Accepted Submission(s)...

alince20008的博客 189

HDU 1133 Buy the Ticket 卡特兰数

设50元的人为+1 100元的人为-1 满足前任意k个人的和大于等于0 卡特兰数 C(n+m, m)-C(n+m, m+1)*n!*m! import java.math.*; import java.util.*; public class Main { /** * @param args */ public static void main(Str

嗯。 1037

HDU 1133 Buy the Ticket 卡特兰数 JAVA

题意:一行人排队买票,一张票50元,有m个持有50面值钞票的人,有n个持有100面值钞票的人。问,有多少种方案能够让窗口可以让前面人的钱把后面人的钱找开来,也就是说持有50面值钞票的人要尽量放在100面值钞票的人的前面。思路:持有50面值钞票的人要尽量放在100面值钞票的人的前面。这是一个卡特兰数的模型了。另外因为每个人是不同的,所有结果要乘上n!n!和m!m!,因为结果比较大,我就偷懒选了java

NM的专栏 479

hdu 1133 Buy the Ticket(卡特兰数 + 高精度)

题目连接:1133 Buy the Ticket 题目大意:有n + m 个人去电影院买票, 每张票卖50块, 现在m 个人手上有50快, n个人手上是100块, 然后电影院的售票厅又没有准备零钱, 问,n + m个人有多少种排队的方式可以使得售票可以不用中断, 中断是因为没有零钱可以找回。 解题思路:问题可以简单理解成将n + m个人排序, 满足任意一个位置前, 拿100的人

不慌不忙、不急不躁 1779

HDU 1133 Buy the Ticket(卡特兰数/递推DP+大数)

Description The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won’t you? Suppose the ...

PleasantlY1的博客 459

hdu 1133 Buy the Ticket(卡特兰数+大整数)

题目原文:http://acm.hdu.edu.cn/showproblem.php?pid=1133 The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have

wchhlbt的博客 494

【卡特兰数Catalan+Java大数BigInteger】HDU-1133 Buy the Ticket

注解 1、此题是Catalan数的变形,如果m=n,则就是标准的卡塔兰数。 2、如果m<n,直接输出0。 3、对于m>n的情况,要转换成排列。化简后的公式为:F(N) =(m+n)!*(m-n+1)/(m+1) 4、必须用大数来解决。 代码 import java.math.BigInteger; import java.util.Scanner; public class Ma...

zhanggirlzhangboy的博客 238

HDU1133 Buy the Ticket (卡特兰数)

Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7990    Accepted Submission(s): 3327   Problem Description The "Harry Potter ...

a984183260的博客 215

【JAVA大数&&卡特兰数】Buy the Ticket HDU - 1133

题目链接 Buy the Ticket HDU - 1133 题目 The “Harry Potter and the Goblet of Fire” will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sigh...

EnjoyingAC的博客 262
上一篇: 二维几何基础模板(一)
下一篇: Codeforces 569A Music
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址