HDU5491 The Next

systermverilog中for循环中的fork join执行情况分析 仅为本人学习记录,如有错误感谢指正! 阅读详情

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5491


题意:一个数对应的二进制的1的个数在[ s1 , s2 ]内,则称为WHY number。

给定一个数字d为WHY number,求比d大的最小的WHY number(即下一个)


思路:先计算出d的二进制中含有1的个数,如果小于上限d2且d是偶数,则答案为d+1。

否则加上lowbit(d),由于加上后1的个数只减不增,故不会出现num1>d2的情况。

若此时符合条件,即为答案。否则补上不足的1(s1-num1),即2^(s1-num1)-1


code:

#include<cstdio>
using namespace std;
typedef long long ll;
ll lowbit(ll x)
{
    return x&-x;
}
ll num1(ll x)
{
    ll res=0;
    while(x)
    {
        if(x&1)
        res++;
        x/=2;
    }
    return res;
}
int main()
{
    int T,cas=1;
    scanf("%d",&T);
    while(T--)
    {
        ll x,s1,s2;
        scanf("%lld%lld%lld",&x,&s1,&s2);
        if((x&1)==0&&s2>num1(x)) x++;
        else
        {
            x+=lowbit(x);
            ll t=num1(x);
            if(t<s1) x+=(1<<(s1-t))-1;
        }
        printf("Case #%d: %lld\n",cas++,x);
    }
    return 0;
}


温度PID控制PLC程序 温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值 立即下载

相关推荐

保姆级教程:在瑞芯微RV1126B上部署轻量化YOLOv8,实现端侧实时目标检测

本文详细介绍了在瑞芯微RV1126B芯片上部署轻量化YOLOv8模型的完整流程,包括开发环境搭建、模型训练优化、量化转换及嵌入式部署。通过利用RV1126B的3TOPS NPU算力和AI-ISP特性,实现端侧实时目标检测,提升边缘AI应用的性能和效率。

weixin_30329623的博客 267

HDU5491 The Next 位模拟

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5491 题目大意:找出比D大的且二进制中1的个数位于区间[S1,S2]内的最小的数。 分析:对于给出的D,我们令D++,然后首先判断D是否属于区间[S1,S2],如果属于,那么D即为答案,否则无异于以下两种情况: (1)D中1的个数小于S1,对于这种情况,我们需要做的就是在增加D的

AC_Gibson的专栏 662

Win11下Android模拟器报HAXM未安装?三步搞定虚拟化配置(附终端命令)

本文详细解析了Win11下Android模拟器HAXM报错的解决方案,从虚拟化配置到终端命令实战。通过检查BIOS设置、调整Windows功能及执行PowerShell命令,三步搞定虚拟化配置问题,有效提升模拟器性能。特别针对Win11与HAXM的兼容性问题提供了专业指导。

weixin_29215815的博客 143

hdu 5491 The Next(位操作)

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5491 思路: 考虑通过比较当前的1的数目来进行最小的数的修正。 先将D加1,然后计算出D的1的数目tot,这时候比较tot和s1,s2的大小,这时候有两种情况: 1、tot 2、tot>s2,这时我需要减少1的数目,所以我从右开始找到一个1,将D加上2^i。 如此循环上述过程,直到

hahahaha 1453

C# HttpClient 实战:3步绕过Cloudflare指纹拦截,获取完整网页内容

本文详细介绍了如何使用C# HttpClient绕过Cloudflare指纹拦截,获取完整网页内容的3步实战方案。通过完美复制浏览器请求头、智能管理Cookie容器以及处理动态挑战页面,开发者可以有效突破Cloudflare的反爬机制,适用于爬虫开发和数据采集项目。

weixin_31856057的博客 320

死磕GMSSL通信-java/Netty系列(二)

Netty-tcnative再linux编译比较好编译,但是再window编译,我尝试了各种办法,总是编译失败,所以我采用半自动的方式进行编译,Netty-tcnative会生成临时文件,直接用vs打开,设置openssl的头文件和静态库路径,然后生成静态库,静态库改个名字放到jar包里边,其实自动编译也是这个原理哈哈O(∩_∩)O。直接传输五个证书的路径吗,之前有的是说要转成x509之类的,转来转去的有点麻烦,这个是直接传输证书路径,由底层gmssl去解析,格式必须是pem格式。然而,若项目已依赖于。

qq_36577699的博客 3025

hdu 5491 The Next

原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=5491 题目大意: T组测试数据。 L,S1,S2。 L的二进制中有x个1,x满足  S1 求满足S1 代码如下: #include #include #include using namespace std; const int MAXN=40; int

sunshine_YG的专栏 1129

新能源汽车动力总成研发测试技术全景深度报告(2025版)

本文所有企业案例数据均来自上市公司财报、工信部备案信息及权威媒体报道,技术参数经第三方检测报告交叉验证。研发测试人员能力矩阵重构(T型人才进阶路径)[10] 全球动力总成市场2035年预测报告。[9] NI电动汽车HIL测试架构技术文档。[3] 东风汽车智能化研发体系深度报告。[5] 混合动力测功机发明专利技术细节。[1] 领克动力总成试验中心技术解析。[7] 新能源汽车产业迭代趋势白皮书。测试架构师-数字工程。测试架构师-安全合规。测试架构师-人工智能。

优快云-新能源汽车研发测试专业博主 777

HDU 5491 The Next

2015 ACM/ICPC Asia Regional Hefei Online Problem Description Let L denote the number of 1s in integer D’s binary representation. Given two integers S1 and S2, we call D a WYH number if S1≤L≤S2. With

仰望星空 689

使用强化学习快速让AI学会玩贪食蛇游戏(轻量级二十分钟训练+代码)

如何让AI玩会贪食蛇,甚至比你厉害概述构建问题(强化学习求解的一般步骤)环境动作定义状态定义奖励设计训练奖励值收敛图效果代码 概述 所用技术:强化学习(Deep Reinforcement Learning),属于一种无监督学习,利用奖励rewardrewardreward教会智能体AgentAgentAgent在合适的场景做合适的决策。 采用算法:试过两种算法D3QN和离散版本的PPO算法,最终采用离散版本PPO算法+GAE(PPO是我用过的性能最好的算法之一) 编程语言与深度学习框架:Python3.

ZYunfei的博客 2万+

回答网友提问:Word 里如何调用 DeepSeek API?

上面的 Visual Basic 定义了名叫 DeepSeekV3 的 subroutine,同理我们可以让 Trae 再写一个调用开启了 DeepThink(R1) 模式的 DeepSeek API,步骤类似,这里不再赘述。在 Word 的 File->Options 选项里,选择 Customize Ribbon,将 Developer 标签从左侧移到右侧,然后在 Developer 标签下新建一个 Group,随便起个名称。API 调用的 response,自动填充到了 Word 里。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 275

HDU 5491 The Next

题意:给你一个数d,和一个范围s1到s2,求比d大并且最接近d的一个数,使得它转化成二进制后数字1的个数在s1到s2内。 解析:位运算,d++,若d的二进制数中1的个数小于s1的话,则找到二进制数中从右向左的第一个0,下标为i,将其转化为1,以此来增加1的个数,则要在d的基础上加2的i次方。 若d的二进制数中1的个数大于s2的话,则找到二进制数中从右向左的第一个1,下标为i,将其转化为0,以此

绿树蓝天碧海的博客 308

从你的全世界路过---陌陌X-SIGN还原

我们上期介绍了hook 接口方式,今天我分析so 层。学习是为了复杂的事情简单化。不用如此繁琐。跟进native_sdbyecbu37x这个函数,我们f5看伪代码 v13 = sign(v9, v10, v11, a6); 跟进这个函数 代码如下(示例): 2.代码贴入 SHA消息摘要java代码如下: java 代码如下(示例): 总结 算法,结合动态调试!

任雪飘的博客 2301

hdu5491 The Next

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 740    Accepted Submission(s): 294 Problem Description Let L denote the number of

新月 716

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

hdu 5491 The Next(位运算+贪心)

题目链接:hdu 5491 The Next解题思路首先将初始的d+1,然后判断二进制先1的个数是否满足。 如果多了,找到最小的i使得s&2^i=1. 如果少了,找到最小的i使得s&2^i=0. 然后s + 2^i,这样保证了每次增加的值最少。代码#include <cstdio> #include <cstring> #include <algorithm>using namespace s

不慌不忙、不急不躁 831

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

HDU 5491 The Next

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5491 The Next Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1118Accepted Submission(...

weixin_30396699的博客 84

深度学习工具包 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 5491 The Next【】

The Next Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2080    Accepted Submission(s): 753 Problem Description Let L denote the

Puya的博客 277

hdu 5491 The Next

Problem Description LetLdenote the number of 1s in integerD’s binary representation. Given two integersS1andS2, we callDa WYH number ifS1≤L≤S2.With a givenD, we would like to find the next ...

weixin_34378969的博客 100

HDU5491-The Next

The Next                                                                            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

wang_128的博客 371

hdu 5491 The Next(数学模拟)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5491 分析:对于给出的D,我们令D++,然后首先判断D是否属于区间[S1,S2],如果属于,那么D即为答案,否则无异于以下两种情况: (1)D中1的个数小于S1,对于这种情况,我们需要做的就是在增加D的同时,增加其二进制中1的个数,我们从其二进制的低位(假设最低位的标号为0)开始找,找到第一个

hexianhao的博客 367

[思路题] hdu 5491 The Next

题意: 找一个最小的比D大的且二进制数含有1的个数在 s1~s2 之间。 保证输出的D的二进制数也在s1~s2之间 思路: 因为D符合题意,所以我们先考虑如果D%2==0,那么加个1会不会超过s2,不会的话 答案就是D+1 那么如果会或者不是1,那么肯定D要发生进位了。 因为要比D大,所以我们把D二进制最后一个1之前的第一个0变成1,这之后都为0 然后从最后开始补1直到符合s1为止

Enmity_Dark 550

HDU 5491 The Next 贪心

The Next Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5491 Description Let L denote the number of 1s in integer D’s binary repres...

weixin_30824277的博客 87
上一篇: HDU5441 Travel 并查集
下一篇: HDU5573 Binary Tree(构造)
西风丶
博客等级 码龄11年 4粉丝 76原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值