hdu 1438 - 钥匙计数之一

HDOJ_1480 钥匙计数之二 解题报告.mht HDOJ_1480 钥匙计数之二 解题报告.mhtHDOJ_1480 钥匙计数之二 解题报告.mht 立即下载

钥匙计数之一

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1112    Accepted Submission(s): 453


Problem Description
一把锁匙有N个槽,槽深为1,2,3,4。每锁匙至少有3个不同的深度且至少有1对相连的槽其深度之差为3。求这样的锁匙的总数。
 

Input
本题无输入
 

Output
对N>=2且N<=31,输出满足要求的锁匙的总数。
 

Sample Output
  
N=2: 0 N=3: 8 N=4: 64 N=5: 360 .. .. .. .. .. .. .. N=31: ... 注:根据Pku Judge Online 1351 Number of Locks或 Xi'an 2002 改编,在那里N<=16


===============================


思路:http://blog.sina.com.cn/s/blog_691495250100y7rt.html

注意pow()的用法


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    long long a[33],b[33],temp;
    a[2]=0;a[3]=8;
    b[2]=0;b[3]=4;
    for(int i=4;i<32;i++)
    {
        a[i]=a[i-1]*4;
        a[i]+=(long long)pow(2.0,i)-4;
        temp=((long long)pow(4.0,i-2)-(long long)pow(2.0,i-2))*2-b[i-1];
        a[i]+=temp;
        b[i]=temp+a[i-1]*2;
    }
    for(int i=2;i<32;i++)
    {
        cout<<"N="<<i<<": "<<a[i]<<endl;
    }
    return 0;
}


Magisk 23.0保姆级教程:用boot.img修补法安全Root安卓设备(附救砖方案) 本文提供基于Magisk 23.0的安卓设备安全Root详细教程,重点讲解通过提取并修补官方boot.img文件的Systemless Root方案。该方法无需修改系统分区,安全性高且支持OTA更新,并附有完整的救砖与风险规避指南,适合追求设备掌控权的用户安全操作。 阅读详情

相关推荐

RTPS规范v2.3(中文版)

DDSI-RTPSv2.3,DDS发现互操作性-实时发布订阅通信协议,中文版

pony12的专栏 757

HDU 1483 钥匙计数之一(详细过程)

HDU 1438  钥匙计数之一 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1438 又是一题递推题,用递推的思路去解。 说来惭愧,做这题的时候有个地方卡住了,直到看了别人的解题报告才豁然开朗(数学没学好。。) 将lock[n]计做n个凹槽时,符合要求的钥匙总数. 将one[n]计做n个凹槽时,第n个凹槽为1时符合要

wintersun的地带 1544

深信服技术认证“SCCA-C”划重点:信服云托管云

该认证包括云数据中心基础、云计算基础、云计算关键技术、云计算交付和运维体系、云计算技术商业应用、信服云托管云、深信服超融合HCI、深信服桌面云aDesk、深信服分布式存储EDS、深信服应用交付AD。学习并获得SCCA-C认证后,可以具备深信服产品功能原理与实践,能够根据业务需求,协助完成云产品方案落地与实施;能够根据业务需求,完成深信服云产品的部署和管理的基本工作。为帮助大家更加系统化地学习云计算知识,高效通过云计算工程师认证,深信服特推出“SCCA-C认证备考秘笈”,共十期内容。

sangfor_edu的博客 620

HDU 1438  钥匙计数之一 (状态压缩或递推)

HDU 1438  钥匙计数之一   Problem Description 一把锁匙有N个槽,槽深为1,2,3,4。每锁匙至少有3个不同的深度且至少有1对相连的槽其深度之差为3。求这样的锁匙的总数。     Input 本题无输入     Output 对N&gt;=2且N&lt;=31,输出满足要求的锁匙的总数。     Sample Output N=2: 0 N...

pxlsdz的博客 595

5分钟搞懂知识抽取:如何把非结构化数据变成知识图谱的宝藏?

本文通过一个电商评论分析实战案例,详细解析了如何利用spaCy、Neo4j等工具,将非结构化文本数据转化为结构化知识图谱的完整流程。文章重点阐述了知识抽取的核心步骤,包括命名实体识别、关系抽取以及知识存储与查询,帮助读者快速掌握将数据转化为知识宝藏的关键技术。

weixin_29054245的博客 238

YOLO26改进策略【模型轻量化】| 替换骨干网络 CVPR-2024 StarNet,超级精简高效的轻量化模块

本文记录的是。YOLO26主要用于轻量化应用部署,相关轻量化改进与其整体架构非常适配。StarNet设计简洁,没有复杂的设计和精细调整的超参数,仅是一个 4 阶段的分层架构。并且其中能够在低维空间计算的同时考虑极高维的特征这一特性,进而提高模型精度。本文在替换骨干网络中配置了原论文中的starnet_s1starnet_s2starnet_s3和starnet_s4七种模型,以满足不同的需求。

Limiiiing的博客 1121

hdu 1438 钥匙计数1

一把锁匙有N个槽,槽深为1,2,3,4。每锁匙至少有3个不同的深度且至少有1对相连的槽其深度之差为3。求这样的锁匙的总数。 递推方程式如下 1:如果X是钥匙 则X1/2/3/4也是 所以a[I]=a[I-1]*4 2: 如果X不是,X2/3是则X由1/4组成/但要除去全1和

路过 878

uniapp [安卓苹果App端] - 实现判断并开启消息通知/提示权限,监测通知权限未开启时弹框提示用户并引导用户跳转至设置界面,uniApp检查通知权限+提示是否打开+点击跳转设置(详细示例代码)

uni-app判断有无通知权限,并进行设置,设置手机通知权限,开启通知权限,uni-app解决权限问题,uniapp 拉起授权(拒绝后重新开启权限)uniApp打包的手机app如果用户没开启通知权限、引导用户开启,uni-app动态打开应用通知权限,拒绝后跳转设置页面,uniapp获取通知栏权限,苹果ios系统打开通知权限,被拒绝怎么办,uniapp安卓判断通知权限,uniapp打包的APP引导用户打开手机通知权限,uniapp权限被拒绝,跳转手机设置页面 权限设置,IOS应用内跳转系统设置,uni-app

🏆 前端领域优质创作者 1万+

HDU - 1438:钥匙计数之一

HDU - 1438:钥匙计数之一 一把锁匙有N个槽,槽深为1,2,3,4。每锁匙至少有3个不同的深度且至少有1对相连的槽其深度之差为3。求这样的锁匙的总数。

Mitsuha_的博客 638

uniapp - 解决真机调试报错 request:fail abort statusCode:-1 java.security.cert.CertPathValidatorException: Tr

uni-app,真机调试报错,app端平台,安卓Android,安卓App发布线上报错,打包后接口请求失效了,api接口报错,真机运行安卓app时接口不通且报错,request:failabortstatusCode:-1java.security.cert.CertPathValidatorException:Trustanchorforcertificationpathnotfound.,真机调试,苹果ios真机报错,Uniapp打包到app后报错,uni-app真机调试报错,服务器

🏆 前端领域优质创作者 1万+

Unity之OpenXR+XR Interaction Toolkit实现 Gaze眼部追踪

在虚拟现实(VR)和增强现实(AR)应用中,眼动追踪是一项强大而受欢迎的技术。它可以让开发者更好地理解用户的注意力和行为,并创造出更加沉浸和智能的体验。在本文中,我们将探讨如何使用 Unity OpenXR 实现Gaze眼部追踪功能。

TxNet 1761

hdu 1438 钥匙计数之一

钥匙计数之一 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 1   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia  Font Size

u010405898的专栏 1693

2024年数字IC秋招-速腾聚创-数字芯片验证工程师-笔试题

笔试题型:单选 + 问答题笔试平台:牛客(手机+电脑监控)笔试时间:1hA. len取10的概率是1/2;B. len取10的概率是1/3;C. len取10的概率是1/4;D. len取10的概率是1;

qq_42135020的博客 1406

hdu1438——钥匙计数

钥匙计数之一 Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2136Accepted Submission(s): 1018 Problem Description 一把锁匙有N个槽,槽深为1,2,3,4。每锁...

weixin_30526593的博客 164

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

hdu 1438 钥匙计数之一

一把钥匙 n 个槽,槽深可为 1、2、3、4,至少有 3 种槽深,至少有两个连续的槽满足深度差为 3。求合法钥匙数。

iTom's blog 487

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

hdu 1438钥匙计数

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1438与解题思路

cc的博客 341

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

hdu1438 钥匙计数之一

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1438 一道非常好的递推题目(感觉较难),解释在代码中 /* F[n]=0; 若前n-1个元素已构成钥匙,F[n]+=4*F[n-1]; 若前n-1个元素构不成钥匙,且加上2/3后构成钥匙,说明前n-1个不满足三个不同元素的要求(只有1/4)F[n]+=2*(2^(n-1)-2),-2为

ZouCharming的专栏 821

HDU - 1438 钥匙计数之一 (状压DP)

钥匙计数之一 一把锁匙有N个槽,槽深为1,2,3,4。每锁匙至少有3个不同的深度且至少有1对相连的槽其深度之差为3。求这样的锁匙的总数。 Input 本题无输入 Output 对N>=2且N<=31,输出满足要求的锁匙的总数。 Sample Output N=2: 0 N=3: 8 N=4: 64 N=5: 360 .. .. .. .. .. .. .. N=...

YOONGI 275

HDU-1438 钥匙计数之一

http://acm.hdu.edu.cn/showproblem.php?pid=1438 钥匙计数之一 Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1...

weixin_30339457的博客 124

钥匙计数之一(递推)hdu1438

钥匙计数之一(递推)hdu1438

寻找&星空の孩子 1449

hdu-1438 钥匙计数之一

题意:略~~~~ 题解:

风儿-zsj的专栏 919

hdu1438 钥匙计数一

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1438 第一次这么认真的做了一道递推的题目,好题啊! 要是自己想还是好吃力,看了解题报告感觉思路好清晰。看解题报告是很不好的习惯,可是菜没办法。。。。。。。。。。呼呼 递推方程: 1 如果X是钥匙,则X1/2/3/4也是。 2如果X不是钥匙,X2/3是。则X是由1和4组成的,除去全部由1或

1377

HDU - 1438——钥匙计数之一 (状压DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1438 思路:dp【i】【j】【k】【flag】:i代表第i个槽,j表示状态,k表示最后一个槽的深度,flag表示是否满足有两个相邻槽深度差为3 #include<algorithm> #include<string.h> #include<stdio.h> u...

creator平 279

HDU 1438(钥匙计数之一)

#include <iostream> #include <cmath> using namespace std; const int MAXN = 35; int main() { __int64 a[MAXN], b[MAXN]; a[2] = 0; b[2] = 0; a[3] = 8; b[3] = 4; for (int i =...

Intelligence1028的博客 208

HDU1438 钥匙计数(状压dp)

原题链接 http://acm.hdu.edu.cn/showproblem.php?pid=1438 题面 题意 一把锁匙有NNN个槽,槽深为1,2,3,41,2,3,41,2,3,4。每锁匙至少有333个不同的深度且至少有111对相连的槽其深度之差为333。求这样的锁匙的总数。 思路 因为状态只有444位,所以考虑状压dpdpdp(暴力) dp[i][j][k][f]dp[i][j][k][...

nuoyanli的博客 1386
上一篇: hdu 2045 - 不容易系列之(3)—— LELE的RPG难题
下一篇: HDU 1079 - Calendar Game
coco430
博客等级 码龄14年 9粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址