Sheldon Numbers Gym - 101128H 构造题,规律

早期颠覆性技术商业化加速:政府主导体系搭建步骤与路径.docx 早期颠覆性技术商业化加速:政府主导体系搭建步骤与路径 立即下载

题意:A代表N个1,B代表M个0,条件是一个数的二进制满足 ABAB...A 或者 ABAB...AB ,可以不含有B,但至少有一个A,求给定L 和 R之间有多少个满足条件的数字。


思路: 数据的范围是0到2^63次方,对1到63长度的数字进行构造。


注意点: pow返回值要进行强制转换!!!!


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <math.h>

using namespace std;

set< unsigned long long> s;

int main()
{
	unsigned long long num; 
	for ( int len = 1; len<=64; len++ ) {
		for ( int a = 1; a<=len ; a++ ) {
			for ( int b = 0; b<=len-a; b++ ) {
				string t = ""; 
				num = 0 ; 
				if ( len%(a+b)==0 ) {
					for ( int i=0; i<len/(a+b); i++ ) {
						t.append(a,'1'); 
						t.append(b,'0'); 
					}
				//	cout<<"shang"<<endl; 
				}
				if ( len%(a+b)==a ) {
					for ( int i=0; i<len/(a+b); i++ ) {
						t.append(a,'1'); 
						t.append(b,'0'); 
					}
					t.append(a,'1'); 
				//	cout<<"xia"<<endl; 
				}
				for ( int i=t.length()-1; i>=0; i-- ) num+=(t[i]-'0')*(long long)pow(2,t.length()-i-1); 		
				s.insert(num); 
				
			}
		}
	}
	
	unsigned long long m,n; 
	cin>>m>>n; 
	
	unsigned long long cnt = 0; 
	s.erase(0); 
	
	set<unsigned long long > ::iterator it; 
	for ( it = s.begin(); it!=s.end(); it++ ) 
	{
		if ( *it>=m && *it<=n ) {
			++cnt ; 
		} 	
	}
	cout<<cnt<<endl; 
	return 0; 
}


科技服务机构促成校企合作时,需遵循哪些规范化操作流程?.docx 科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。 立即下载

相关推荐

从零到一:Mx_yolo本地训练与K210部署实战指南

本文详细介绍了从零开始进行Mx_yolo本地模型训练到K210部署的全流程实战指南。涵盖环境配置、数据准备、模型训练与调优、模型转换及K210部署等关键步骤,并提供了常见问题解决方案和性能优化技巧,帮助开发者高效完成AI模型在嵌入式设备的落地应用。

weixin_29081163的博客 259

CodeForces Gym 102012 简要题解

Rikka with Minimum Spanning Trees 因为数据随机,所以MST只有 111 种。注意特判不连通的情况。 #include &lt;bits/stdc++.h&gt; using namespace std; typedef unsigned long long ull; const int N = 123456; const int md = 1e9 + 7; ...

wxh010910 6984

Cisco Packet Tracer 7.3免登录技巧:3种方法快速跳过注册界面(附详细截图)

本文针对Cisco Packet Tracer 7.3启动时遇到的登录界面问题,提供了三种合法高效的解决方案。详细介绍了如何利用官方访客模式快速启动、注册思科账号实现一劳永逸登录,以及通过调整本地安装配置优化启动流程,帮助网络学习者与备考者绕过繁琐步骤,快速进入实验环境。

weixin_29305337的博客 766

[想法题]Gym 101128H

Sheldon Numbers According to Sheldon Cooper, the best number is 73. In his own words, “The best number is 73. 73 is the 21st prime number. Its mirror, 37, is the 12th, and its mirror, 21, is the produ...

Mr_Alice的博客 574

AD620仪表放大器模组实战:从调零到信号放大的完整指南

本文详细介绍了AD620仪表放大器模组的实战应用,从调零到信号放大的完整指南。AD620模组以其专业级性能和易用性成为微弱信号放大的首选,集成了AD620芯片、LM358运放和7660电源转换芯片。文章提供了调零技巧、增益设置方法以及单端与差分输入的正确连接方案,并通过心电信号采集和称重传感器等实际案例展示了其广泛应用。

weixin_29290379的博客 384

NVIDIA Isaac Sim 联合 VS Code 开发调试环境配置

在 Visual Studio Code (VS Code) 中打开 Isaac Sim 软件包主文件夹,即可打开该工作区。注意建议在学习教程和示例时使用 Visual Studio Code。另请参见有关 VS Code 工作区的详细信息,请参阅 Visual Studio Code (VS Code) 文档。

2506_90492529的博客 3117

Sheldon Numbers Gym - 101128H 思维枚举

题目链接 题意: 问区间[x,y]中有多少数的二进制表示是ABAB..AB型或者A型的,其中A是n个1,B是m个0,n,m>0  思路: 对于这个题的话 我们知道满足条件的且在(x,y)的,那么其二进制位数肯定也在x和y所对应的二进制位数之间; 所以在这里我们可以先求出x,y所对应的二进制位数,然后在这个位数区间内枚举所有满足情况的解,当然也有一些是大于y的 我们要去掉.

Marcus-Bao的个人主页 967

Calibre 3Dstack --每日一个命令day27【overlap】(3-27)

本文介绍了Calibre3Dstack中overlap命令的使用方法。该命令用于检查两个已放置层之间的重叠量是否符合要求,支持设置检查名称、层类型、堆叠范围、检查方向等参数。关键参数包括:-constraint指定重叠约束条件,-exact控制百分比精度,-by_area切换为面积检查模式,-intersection报告相交区域。检查结果可通过RVE选项定制显示方式,适用于3D堆叠设计中的层间重叠验证场景。

u013620135的博客 117

Gym102012 - 2018徐州 - G - Rikka with Intersections of Paths (树上差分 + 组合数)

题目链接 给出一棵树,然后在树上标记条路径,问有多少种方法在这条路径中选出条,使得这条路径至少有一个公共点。 枚举每个作为路径交的点,假设经过某点的路径数为,其中有条路径的LCA为这个点,那么此处的计数就是。 这相当于减去了经过这个点的父节点的路径在此处计数中的贡献。 维护经过某点的路径数用树上差分,对于和之间的路径, 。 Time :1216ms #include &lt;cst...

NPU_SXY的博客 1591

解决RabbitMq登录时报出Not management user(Login failed)错误以及rabbitmqctl(RabbitMq)新增用户和用户角色权限

解决RabbitMq登录时报出Not management user(Login failed)错误以及rabbitmqctl(RabbitMq)查看用户权限、新增用户和用户角色权限。

念兮为美 7484

28.Anaconda安装jupyter notebook、jupyterlab及体验

手贱,不小心将Anaconda自带得jupyter给卸载了,没法子了查了好多资料都比较麻烦,所以自己摸索着重新安装,记录一下心得。说明:Anaconda没有加入环境变量,Anaconda官方建议不要将Anaconda加入环境变量,这就意味着他和python是可以共存的。

迷逝 5038

Gym - 101128H - Sheldon Numbers

Gym - 101128H - Sheldon Numbers 原命题链接 写在前面 这是一道在学校比赛的时候遇到的题目,当时就觉得可以敲,一开始是纯暴力枚举判断,结果正确但是严重超时,后来改成了暴力打表判断,没控制好个数,比赛的时候心里也很紧张,就没有AC过这一道题,现在重写代码,AC。 题目大意 说一下题目的大体意思:每个数字的二进制的表示形式,如果,在一个01循环内部将1...

FancyKing的博客 434

iqoo11如何获取root权限?

🏆本文收录于专栏,主要记录项目实战过程中所遇到的Bug或因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家!持续更新中,up!up!up!!

**My Coding Family** 5921

预处理 Gym - 101128H

题目链接:http://codeforces.com/gym/101128 题目大意:给你一个区间[x,y],找出这个区间有多少个seldom的数字。 seldom的数字定义如下:该数值的二进制数字符合如下条件ABAB...ABAB 或者 ABABA....BA,其中A表示连续的1的个数,B表示连续的0的个数。 思路:因为长度只有63,本来以为是数位dp的,想了想直接暴力预...

weixin_33802505的博客 156

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

树上差分(Gym - 102012G Rikka with Intersections of Paths)

题目链接 听说是当年徐州现场赛的银牌的(从银牌到打铁全是2题队,太可怕了)。 很容易想到的就是树上差分,但是显然是算重了。怎么去重是重点。。这里有一个理论。 一个树上任意两条路径如果有交点的话,那么这些交点中肯定有一个为两条路径中的一条路径两端点的lca 这就很奇妙了?不太清楚是怎么推出来的。 如果借此理论,题目就好做了。对于每个点: ans = C(cnt, k) - C(cnt - lc...

平凡人Kalzn的博客 814

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

J.Jumbled String-----Gym101933(关于构造类题)

Jumbled String Time Limit: 1 Sec Memory Limit: 128 Mb 题目链接http://acm.csu.edu.cn:20080/csuoj/contest/problem?cid=2178&amp;amp;amp;amp;pid=J Description Recall that a subsequence of a string is any string obtai...

孤风的博客 523

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

GYM 101128 C.Canvas Painting(优先队列)

Description 给n件白色货物染色,先把这些货物按顺序放好,然后选定一个颜色C和一个数量F,之后把前F个颜色为C的货物染成X颜色,把剩余的颜色为C的货物染成Y颜色,X和Y是与所有出现过的颜色不用的两种不同颜色,问最少需多少颜料才能把每件货物都染上不同颜色 Input 第一行一整数T表示用例组数,每组用例首先输入一整数n表示货物数量,之后输入n个整数a[i]表示给第i件货物染色需要多少颜

ZSQ 948

Gym 102012G Rikka with Intersections of Paths (树上差分+LCA)

#include<bits/stdc++.h> using namespace std; #define debug cout<<"YES\n"; #define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++) #define ll long long #define lrt int l,int r,int rt #define ...

满月照亮的路 560

Gym 101466 部分题解

题目链接 纪念一下和库里布莱恩特的这场菜鸡互啄。 3星Gym,一共做出来7个题。感觉最大的收获就是意识到了二分的重要性,还有就是学习到了一种新的排序方法——计数排序(好像又叫桶排序)。下面根据题的难度从简到难记录一下。 H题: 按照题意打印即可。 #include<iostream> #include<iomanip> #include<cstdio&gt...

flyzer的博客 341

GYM 101128 H.Sheldon Numbers(枚举)

Description 问区间[x,y]中有多少数的二进制表示是ABAB..AB型或者A型的,其中A是n个1,B是m个0,n,m>0 Input 两个整数x和y(0<=x,y < 2^63) Output 输出[x,y]中有多少满足条件的数 Sample Input 1 10 Sample Output 10 Solution 直接枚举n,m和二进制表示的长度即可 Code#

ZSQ 918

GYM 101128H Sheldon Numbers

原题如 Description  问区间[x,y]中有多少数的二进制表示是ABAB..AB型或者A型的,其中A是n个1,B是m个0,n, m > 0  Input  两个整数x和y(0 Output  输出[x,y]中有多少满足条件的数  Sample Input  1 10  Sample Output  10  思路:先构建模板,像110, 111

yo_bc的博客 709

Gym - 101128H

暴力枚举1和0 的个数,可太水了,,,之前写了一发wa。wa在我武断的以为1的个数一定要大于0,还有重复计算了0的个数为1的情况。还有我的写法要特判一下X=0的时候#include &lt;iostream&gt; #include&lt;algorithm&gt; #include&lt;cstdio&gt; #include&lt;string&gt; #include&lt;string&g...

DS00HY的小博客 300

Gym102012 - 2018徐州 - G - Rikka with Intersections of Paths

这题我一开始的思路是,对于点相交的集合,直接统计即可。对于边相交的集合。不妨算作为这条边深度最大的点的贡献。 尼玛,这明显有重啊,我是智障吗。。。所以正解是对于边相交的集合。算作为这条边深度最小的点的贡献。 等下,又坑: (x - y) % mod是错误的,正确应写成 ( x-y+mod )%mod #include<bits/stdc++.h> using ...

ehdhg13455的博客 466

codeforces gym 100286 H - Hell on the Markets (贪心算法)

题目链接 题意:n个数分别为a[i],问是否存在一组对应的b[i],b[i]=1 || b[i]=-1,使得ai*bi的n项和为0。 题解: 先证明一个结论吧,对于1≤ai≤i+1,前面ai个数一定可以凑出1~sum[i]中的任意一个数. 对于i=1显然成立,假设对于i=k结论成立,那么对于i=k+1来说,只要证明sum[k]+i,1≤i≤ak+1可以凑出来就行了。 因为sum[k]+i...

weixin_30912051的博客 189

[DP] Codeforces Gym 101002 H. Jewel Thief

它是个背包 我们就做背包 因为体积范围很小 我们按体积分类 然后因为当我们决策某个体积拿多少个时肯定拿价值大的前几个 我们按体积划分阶段DP 然后发现转移都是在差为体积整数倍之间 按照容量对体积取模分组 发现组内部转移满足神奇的决策单调性?! 然后就大力分治一发 O(KClogC)O(KC \log C)正解肯定不是这个 正解肯定不是这个 正解肯定不是这个 正解真的不是这个 应该O(KC

雯舞 848
上一篇: Canvas Painting Gym - 101128C ,优先队列,哈夫曼树
下一篇: UVALive 7267 Mysterious Antiques in Sackler Museum 思维题 拼接矩形
Peppermint__
博客等级 码龄10年 4粉丝 72原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值