HDOJ 1342

HDOJ.1342 Lotto (DFS) Lotto点我挑战题目题意分析给出k(6 < k < 13)个数字,要求从这k个数字中选出升序的6个数字,并且按照字典序输出全部的可能,给出的k个数字已经按照升序排列好。 乍一看以为是排列组合,怎么想也想不到是用dfs来解决。按照这个数字选或者不选的逻辑,以为是dp什么的。最后看了题解才知道用dfs的方法做,也算是长见识了。作为dfs的第一道题,好好写,纪念一下。 dfs一般采用递归写法,或许是 阅读详情

经典深搜题目,水题

注意题目要求的输出,最后一组数据输出后不用再输出空行

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


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int s[15],k,a[15];
bool used[15];

void dfs(int num,int x){ //num记录第几个数 ,x记录扫描到s数组的当前位置
    if (x==k && num<6) return;
    if (num==6) {
        for (int i=1;i<6;i++) printf("%d ",a[i]);
        printf("%d\n",a[6]);
        return;
    }
    for (int i=x+1;i<=k;i++){
        a[num+1]=s[i];
        dfs(num+1,i);
    }
}

int main(){
    cin>>k;
    while (1){
        for (int i=1;i<=k;i++){
            scanf("%d",&s[i]);
        }
        for (int i=1;i<=k-5;i++) {
                a[1]=s[i];
                dfs(1,i);
        }
        cin>>k;
        if (k!=0) printf("\n");
        else break;
    }
    return 0;
}


HDOJ1342. Lotto(基础DFS) LottoTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3584    Accepted Submission(s): 1705Problem DescriptionIn a Lotto I have ever played, one h... 阅读详情

相关推荐

windows中如何将已安装的nodejs高版本降级为低版本

第一步:先清空本地安装的node.js版本 1.按健win+R弹出窗口,键盘输入cmd,然后敲回车(或者鼠标直接点击电脑左面最左下角的win窗口图标弹出,输入cmd再点击回车键) 然后进入命令控制行窗口,并输入where node查看之前本地安装的node的路径 2.找到上面找到的路径,将node.exe所在的父目录里面的所有东西都删除 3.为了彻底删除之前安装的node.js,鼠标点击电脑左面最左下角的win窗口图标弹出,输入“控制面板”再点击回车键进入,进入控制面板后,找到所安装的node.js并

weixin_44582077的博客 9万+

hdoj1342

很简单的题,让你在一个集合中,选六个数,要升序,把他们打印出来,这个题唯一要注意的是输出的格式 代码如下: #include #include #include using namespace std; int a[55],vis[55]; int b[55]; int n; void dfs(int num) { if(num==6) { cout<<b[0]

龙崎的专栏 729

高德地图JSAPI中旋转Marker点标签图片时候,且不旋转lable内容方法。

高德地图JSAPI中旋转Marker点标签图片时候,且不旋转lable内容方法

weixin_42960380的博客 2504

HDOJ1342 Lotto(DFS,回溯)

HDOJ 1342 很经典的DFS框架。题意是输出6个满足升序的所有情况。 DFS的两个参数,一个保存当前的搜索位置,一个保存储存的个数。#include <iostream> #include<cstdio> #include<string.h> #include<algorithm> #include<queue> using namespace std; int k,vis[110],a[

xx_ii 561

评价模型——层次分析法(AHP)与熵权法(EWM)

层次分析法是定性与定量结合的多准则决策、评价方法。将决策的有关元素分解成目标层、准则层和方案层,并通过人们的判断对决策方案的优劣进行排序,在此基础上进行定性和定量分析。它把人的思维过程层次化、数量化,并用数学为分析、决策、评价、预报和控制提供定量的依据。

好好学习 天天向上 2万+

从零到一:树莓派OpenWrt squashfs固件扩容背后的文件系统魔法

本文深入解析树莓派OpenWrt系统中squashfs固件的扩容原理与操作。通过理解squashfs与overlayfs的协同机制,掌握分区调整和文件系统扩容技巧,解决存储空间限制问题,提升设备可用性。

hadoop5ranger的博客 1040

hdu1342 Lotto

LottoTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 523 Accepted Submission(s): 288Problem DescriptionIn a Lotto I have ever played, one has...

weixin_30511107的博客 160

DSSAT模型实战:从基础配置到气候情景模拟

本文详细介绍了DSSAT模型在农业模拟中的应用,从基础配置到气候情景模拟的全流程实战指南。通过土壤-植物-大气连续体的动态关系建模,DSSAT能精准预测作物产量,误差率低至8%。文章涵盖气象数据处理、土壤参数配置、管理措施调控等核心技巧,并提供了Python脚本和可视化方法,助力农业科研与决策。

weixin_29264201的博客 1029

HDU1342 Lotto 【深搜】

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1411    Accepted Submission(s): 697 Problem Description In a Lotto I have eve

长风的专栏 1462

【WRF-GHG 教程第一期】概述(Overview)

概述(Overview)

WW、forever的博客 519

Mac安装Typescript报错

根本原因是系统级目录的权限限制。推荐通过修改目录权限或使用nvm彻底解决问题。

江拥羡橙的博客 216

hdoj 1342 Lotto

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1734    Accepted Submission(s): 853 Problem Description In a Lotto I have ever pl

longge33445的博客 470

《C++面向对象程序设计》✍千处细节、万字总结(建议收藏)

《C++面向对象程序设计》✍千处细节、万字总结 文章目录《C++面向对象程序设计》✍千处细节、万字总结一、面向对象程序设计二、C++基础2.1 C++的产生和特点2.2 一个简单的C++示例程序2.3 C++在非面向对象方面对C语言的扩充输入和输出cinconst修饰符void型指针内联函数带有默认参数值的函数函数重载作用域标识符"::"强制类型转换new和delete运算符引用三、类和对象(一)3.1 类的构成3.2 成员函数的定义3.3 对象的定义和使用3.4 构造函数与析构函数构造函数成员初始化列表

像写诗一样优雅地写代码~ 78万+

hdoj_1342Lotto

Lotto Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1142Accepted Submission(s): ...

chouchijiao8952的博客 116

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

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

HDOJ 1342 Lotto

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1342题意:In a Lotto I have ever played, one has to select 6 numbers from the set {1,2,...,49}.

Ocean 717

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

hdoj1342Lotto【dfs】

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1882    Accepted Submission(s): 917 Problem Description In a Lotto I have eve

走一步再走一步 415

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

HDOJ 1342 DFS

#include #include"sstream" #include"string" #include"algorithm" #include"cstring" #include"cstdio" using namespace std; int g[300]; int r,c; int visit[300]; int a[100]; int n; int ka=1; void dfs(int

不要挡住我的阳光 322

hdoj1342 Lotto

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1809    Accepted Submission(s): 881 Problem Description In a Lotto I have eve

张小象 415

hdu1342&poj2245Lotto - dfs

hud1342 dfs第二题 不怎么熟练 看了别人的代码 //hdu 1342 poj2245 #include #include using namespace std; int ans[6],S[20]; void dfs(int k,int next,int n) { int i,j; if(n==7) { for(i=1;i<=6;i++)

Time flies 852

hdoj 1342 Lotto 【经典DFS】 【附上三种DFS写法】

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1727    Accepted Submission(s): 848 Problem Description In a Lotto I have eve

世界很大 1292

HDOJ1342lotto(DFS)

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1755    Accepted Submission(s): 860 Problem Description In a Lotto I have ever

青爷 336

HDOJ 题目1342Lotto(DFS)

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1574    Accepted Submission(s): 779 Problem Description In a Lotto I have eve

Jogging_Clown 583

「DFS」从不同的一组数中选取k个数的总方法

例题:HDOJ1342 题目大意: 输出从给定的k个数中选取6个数的所有选取方法 题解: dfs的入门题型是全排列题,其实和这类题很像 全排列题目中dfs函数的写法: void dfs(int step){ if(step==Volume+1){ 输出标记数组 } for(int i=0;i<Volume;i++){ if(vis[a[i]]==0{ b.push_back(a[i]); vis[a[i]]=1; dfs(step+1); b.pop_back(

weixin_45650172的博客 355

hdoj--1342--Lotto(dfs)

Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1887    Accepted Submission(s): 919 Problem Description In a Lotto I have ever

playboy307 275
上一篇: HDOJ1010 Tempter of the Bone
下一篇: 宽搜入门代码模板详解 HDOJ1253
罗侯
博客等级 码龄10年 135粉丝 258原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值