hdu 4349 Xiao Ming's Hope

投第一篇SCIE英文期刊(详细步骤) 一个投稿SCIE英文期刊的过程 阅读详情

/*

方法一

Accepted4349859MS228K302 BC++

先来补充一下二项式奇偶性的知识

C(n, k) 若n&k == k,则为奇数,否则为偶数

证明比较复杂,想知道的百度一下就有了

*/

#include<iostream>
using namespace std;

int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
        int i, ans=0;
        for( i=0; i <= n/2; i++ )
        {
            if((n&i) == i)
                ans++;
        }
        printf("%d\n", ans*2);
    }
    return 0;
}
 /*

Accepted434931MS228K307 BC++

Lucas定理应用

        Lucas定理:把n写成p进制a[n]a[n-1]a[n-2]...a[0],把m写成p进制b[n]b[n-1]b[n-2]...b[0],

则C(n,m)与C(a[n],b[n])*C(a[n-1],b[n-1])*C(a[n-2],b[-2])*....*C(a[0],b[0])模p同余。

开始看这句话的时候是一头雾水


这题p为2,就是都把n,m转换成二进制,比如说n=44,二进制为n=101100,m从000000遍历到1111111,以为C(0, 0)==C(1, 0)==C(1, 1) == 1;只有C(0,1)==0;所以二进制n有0的位置m在该位置必须也为0,n原本是1的地方可以填0或1都可以,本题就简化为计算二进制数中1的个数,根据排列组合,易得有2^t .(t表示1的个数)

*/

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
	int n;
	while(scanf("%d", &n) != EOF )
	{
		int t=0;//t计数而进制n中1的个数
		for(n)
		{
			if(n&1)//n%=2;
				t++;
			n >>= 1;//n /= 2
		}
		printf("%d\n", 1<<t);//表示2^t
	}
	return 0;
}


【2025软考高级架构师】论文篇——4、论可靠性系统中软件容错技术的应用 软件容错技术对软件的稳定性起着至关重要的作用,尤其是针对互联网性质的软件并发高存在流量峰值等问题,软件容错技术的应用的重要性就不言而喻了。经过这次我所采用的软件容错技术的方法和措施的实施效果后,使我也看到了自己身上的不足之处,我会在今后的架构设计过程中,不断更新自己的知识,不断完善自己的架构设计领域,设计出更好的软件架构,更好的支撑业务平台的运行,提高公司的竞争力,为公司为社会尽一份绵薄之力。 阅读详情

相关推荐

Win11注册表没有MMC的解决方法

本文详细介绍了在Win11系统中解决注册表没有MMC项的问题的方法。通过创建并导入注册表修复文件,我们可以成功地在注册表中添加缺失的MMC项。在操作过程中,需要注意备份注册表、以管理员身份运行工具以及系统更新等事项。希望本文能够帮助到遇到类似问题的用户,提高系统管理的效率和便捷性。如果你还有其他关于Windows操作系统的问题或疑问,欢迎随时提问并寻求帮助。

nntxthml的博客 1559

HDU 4349 Xiao Ming's Hope(Lucas定理的推导)

Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1294    Accepted Submission(s): 875 Problem Description Xiao Ming like

风尘_浪子 1524

手眼标定(EyeToHand)推导

Base为基坐标系(B),工具末端坐标系(T),标定板为Mark坐标系(M),相机坐标系(C)对于每两个姿态都存在上式,组成一个AX=XB的矩阵方程,X为。此时转换成AX=0的问题,单纯用SVD求奇异解便可得到。相机坐标系到Base基坐标系下的转换关系。已知标定板与机械臂末端的相对位置固定不变,,即。带入(2)式求,至此求解出需要的手眼矩阵。在眼在手外的时候,其实是要求解。

stevenreally6的博客 1146

HDU 4349 Xiao Ming's Hope

一、题目 题目描述 求C(n,0),C(n,1)...C(n,n)C(n,0),C(n,1)...C(n,n)C(n,0),C(n,1)...C(n,n)有多少个是奇数 数据范围 1≤n≤1e81\leq n\leq 1e81≤n≤1e8 二、解法 这道题只关乎奇偶性,所以可以默认模数为222,我们尝试用lucas\text{lucas}lucas,设aaa为nnn的二进制分解,bbb为iii的二...

C202044zxy的博客 213

Raid5损坏两块盘

  以下为浪潮Inspur NF5460M4型号服务器故障处理过程: 设备raid5组损坏两块硬,并raid组处理离线状态,情况如图:     由于硬盘数据比较重要,面对此情况不要慌我们尽量做到安全保守的保证数据尽可能完整,以下为处理方法,(遇raid5两块盘出现问题处理方法)   以下截图均为遇相同问题的解决图案,并非现场截图。 Ctrl+H 进WebBios界面,发现两...

chen_lipeng的博客 2万+

利用LTspice设计Pt100测温电路

是一种广泛使用的温度传感器,它属于(RTD, Resistance Temperature Detector)的类型,通常用于温度测量。在0°C时,的电阻值为100欧姆,且它的电阻值会随着温度的升高而升高。PT100热电阻温度阻值对应表)因此可以根据这一特性来检测出环境温度。

2301_77033628的博客 2427

HDU4349-Xiao Ming's Hope(Lucas定理)

Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2435    Accepted Submission(s): 1674 Problem Description Xiao Ming

du_lun的博客 558

【华为OD机试真题 新系统】960、 面试叫号系统 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS)

【华为OD机试真题 2026C卷】960、 面试叫号系统 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS) 华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2025e卷,od机试,2025E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2025华为od,如何备战华

KJ.JK 2376

HDU 4349 Xiao Ming's Hope 组合数学

来源:http://acm.hdu.edu.cn/showproblem.php?pid=4349 题意:求C(n,0),C(n,1),C(n,2)...C(n,n).当中有多少个奇数。 思路:表示比赛时是水过的,求出了前8个数,发现都是2的幂,然后就发现规律了。就是n转化为二进制后又多少个1,就是2的多少次方。解题报告说是Lucas定理,不知道Lucas定理是什么,也没看懂证明。。太弱了

1835

使用CubeMX配置STM32H7的FreeRTOS

本文将介绍如何使用CubeMX配置STM32H7的FreeRTOS,并提供相应的源代码示例。通过使用CubeMX,你可以轻松地配置FreeRTOS和系统资源,并生成相应的初始化代码和配置文件。在"FreeRTOS"选项卡的"Tasks"部分,可以配置系统中的任务。首先,打开CubeMX软件。在"FreeRTOS"选项卡的"Resources"部分,你可以配置FreeRTOS使用的资源,例如,堆内存和信号量。例如,我们可以创建两个简单的任务,一个任务将在循环中切换LED的状态,另一个任务将通过串口打印消息。

JeeVue的博客 721

【零基础入门unity游戏开发——unity通用篇12】导入导出unity资源包、设置编程工具、创建脚本(组件)规则、MonoBehaviour基类介绍、脚本模板(基于unity6开发介绍)

导入导出unity资源包、设置编程工具、创建脚本(组件)规则、MonoBehaviour基类介绍、脚本模板(基于unity6开发介绍)

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 772

hdu 4349——Xiao Ming's Hope

题意:给定n,让求c(n,0),c(n,1)……c(n,n)中有多少奇数。思路:本题为Lucas定理推导题,我们分析一下 C(n,m)%2,那么由lucas定理,我们可以写 成二进制的形式观察,比如 n=1001101,m是从000000到1001101的枚举,我们知道在该定理中 C(0,1)=0,因此如果n=1001101的0对应位置的m二进制位为1那么C(n,m) % 2==0,因此m对应n为0

坚持不懈 424

Xilinx FPGA ICAP原语实现多重配置

众所周知,常见的FPGA通常为SRAM结构,固件程序一般存放在外置的串行Flash中,比如SPI Flash,M25P16或N25Q128等。 FPGA启动时,一般先从SPI起始地址开始加载数据到内部的SRAM,加载完成、校验通过则会直接运行。 那么有没有可能在SPI Flash中存放两个或多个FPGA固件呢?

whik1194的博客 4622

HDU 4349 Xiao Ming's Hope(Lucas定理、C[n][m]为奇数的个数)

题目链接: HDU 4349 Xiao Ming’s Hope 题意: 给定nn求Cmn(0≤m≤n,n≤108)为奇数的mC_{n}^{m}(0\leq m\leq n,n\leq 10^8)为奇数的m个数。 分析: 即Cmn %2=1的m个数C_{n}^{m}\ \%2=1的m个数,考虑将n和mn和m都表示成22的幂次组合形式,则任意的系数ni和min_i和m_i非0即1.因为C00=

ramay7 605

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

HDU4349 Xiao Ming's Hope Lucas定理

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4349 题目大意:找出杨辉三角第n+1行中有多少个奇数。 分析:n的范围比较大(10^8数量级),考虑到大组合数取模(找奇数,即对2取模)的问题,自然而然就想到Lucas了(关于Lucas定理:点击打开链接)。我们知道对于求C(n,m)mod p,Lucas定理是把组合数中的n和m换

AC_Gibson的专栏 647

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

【HDU - 4349】Xiao Ming's Hope

BUPT2017 wintertraining(15) #8H 题意 求组合数C(n,i),i从0到n,里面有几个奇数。 题解 直接打表的话可能就直接发现规律了。 规律是n的二进制里有几个1,答案就是2的几次方。 证明: lucas定理有:C(n,m)%p=C(n/p,m/p)*C(n%p,m%p)%p 然后取p为2。 所以展开后是C(0,0),C(0,1),C(1,0),C(1,1)的...

dingguayi7025的博客 124

深度学习工具包 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 4349 Xiao Ming's Hope 组合数学 奇偶性

hdu 4349 Xiao Ming’s Hope/* * zw.cpp * * Created on: 2016-7-20 * Author: callmedaddy */#include<iostream> #include<cstdio> #include<iomanip> #include<cstdlib> #include<cstring> #include<algo

callmedaddy的博客 675

[HDU 4349] Xiao Ming's Hope (lucas定理)

HDU - 4349 给定n求满足 C(n,m)为奇数的 m的个数 首先朴素的想法是把每一个组合数都求出来 但是组合数比较大,所以自然的就想到 mod 2 所以很关键的一点是要转化为 C(n,m)%2 即 C(n,m)%2 = 1 的m的个数 利用lucas定理展开,审视乘积中的每一个组合数 由于 C(0,0) = C(1,0) = C(1,1) = 1,C(0,1) = 0 所以要

MisDeer's blog 301

HDU 4349--Xiao Ming's Hope

来源:http://acm.hdu.edu.cn/showproblem.php?pid=4349 题意:求C(n,0),C(n,1),C(n,2)...C(n,n).当中有多少个奇数。 就是求n用二进制表示时,其中1的个数,具体可用lacus定理证明。 #include #include #include #include #include #include #include

Xcockroach的专栏 886

hdu 4349 Xiao Ming's Hope,lucas定理

Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1793    Accepted Submission(s): 1189 Problem Description Xiao Ming

G.D.Retop的专栏 647

hdu 4349 Xiao Ming's Hope(Lucas定理)

题意:求C(n,0),C(n,1),C(n,2)……C(n,n)中奇数的个数。 思路:Lucas定理的一个推论,把C(n,m)看做用二进制表示,那么为奇数的条件是n的每一位都大于等于m的对应位,因此答案是2^(n的二进制表示中1的个数)。 代码: #include #include #include #include #include #include #include #include #

绝望的乐园 829

Hdu4349 Xiao Ming's Hope

Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1668Accepted Submission(s): 1109 Problem Description Xiao Ming likes cou...

weixin_30725467的博客 135

hdu - 4349 Xiao Ming's Hope Lucs

Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2609    Accepted Submission(s): 1790   Problem Description Xiao Ming likes ...

Sean 290

HDU - 4349 Xiao Ming's Hope lucas定理

题目:求c(n,0),c(n,1),...,c(n,n)中有多少个奇数 思路: C(n,m)%2,那么由lucas定理,我们可以写成二进制的形式观察, 比如 n=1001101,m是从000000到1001101的枚举,我们知道在该定理中 C(0,1)=0,因此如果n=1001101的0对应位置的m二进制位为1那么C(n,m) % 2==0,因此m对应n为0的 位置只能填0,而1的位置填

ACVevtor的博客 433
上一篇: hdu 1114 Piggy-Bank
下一篇: hdu 3817 Triangle
asure__cpp
博客等级 码龄14年 8粉丝 150原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值