hdu 4801 Pocket Cube

深度学习环境搭建:CUDA、Anaconda、PyTorch 完整安装与验证教程 步骤操作验证命令1安装 CUDA 工具包nvcc -V2安装 Anaconda3创建 yolo 环境4安装 PyTorch5验证 GPU。 阅读详情

        题意:给出一个Pocket Cube的状态,问n步(每步只能顺时针转90度)最多能还原几个面。

        思路:作为一个Cuber,看到这种题非常激动,凭着自己对魔方突(yi)破(dian)天(dian)际的理解A掉了。。。这里我用的是dfs+回溯,因为把魔方的状态转成int的哈希不是那么好写,所以没有写状态判重,直接回溯解决。然后,其实六个面的旋转只需要写三个函数,因为相对的面的旋转其实是等效的。

        写这个题要非常细心。。因为里面有很多常数。。


#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
#include<string.h>
#include<cstdio>

using namespace std;

#define ll long long

int judge(int* a){
    int re=0;
    if(a[0]==a[1]&&a[0]==a[2]&&a[0]==a[3])re++;
    if(a[4]==a[5]&&a[4]==a[10]&&a[4]==a[11])re++;
    if(a[6]==a[7]&&a[6]==a[12]&&a[6]==a[13])re++;
    if(a[16]==a[17]&&a[16]==a[18]&&a[16]==a[19])re++;
    if(a[8]==a[9]&&a[8]==a[14]&&a[8]==a[15])re++;
    if(a[20]==a[21]&&a[20]==a[22]&&a[20]==a[23])re++;
    return re;
}


int a[24];

void r(){
    int b[24];
    memcpy(b,a,sizeof(a));
    a[1]=b[7];
    a[3]=b[13];
    a[7]=b[17];
    a[13]=b[19];
    a[17]=b[21];
    a[19]=b[23];
    a[21]=b[1];
    a[23]=b[3];
    a[8]=b[14];
    a[9]=b[8];
    a[15]=b[9];
    a[14]=b[15];
}

void u(){
    int b[24];
    memcpy(b,a,sizeof(a));
    a[4]=b[6];
    a[5]=b[7];
    a[6]=b[8];
    a[7]=b[9];
    a[8]=b[23];
    a[9]=b[22];
    a[23]=b[4];
    a[22]=b[5];
    a[0]=b[2];
    a[1]=b[0];
    a[3]=b[1];
    a[2]=b[3];
}

void f(){
    int b[24];
    memcpy(b,a,sizeof(a));
    a[2]=b[11];
    a[3]=b[5];
    a[8]=b[2];
    a[14]=b[3];
    a[17]=b[8];
    a[16]=b[14];
    a[11]=b[17];
    a[5]=b[16];
    a[6]=b[12];
    a[7]=b[6];
    a[13]=b[7];
    a[12]=b[13];
}

int n;
int ans;
void dfs(int d){
    if(d>n||ans==6)return;//剪枝,因为最多6面
    ans=max(ans,judge(a));
    u();
    dfs(d+1);
    u();    u();    u();
    
    r();
    dfs(d+1);
    r();    r();    r();

    f();
    dfs(d+1);
    f();    f();    f();
//相当于d
    u();    u();    u();
    dfs(d+1);
    u();
//相当于l
    r();    r();    r();
    dfs(d+1);
    r();
//相当于b
    f();    f();    f();
    dfs(d+1);
    f();
}

int main(){
    while(cin>>n){
        ans=0;
        for(int i=0;i<24;i++){
            scanf("%d",&a[i]);
        }
        dfs(0);
        cout<<ans<<endl;
    }
    return 0;
}


ardupilot 为什么要采样四元数姿态控制 本节主要说明清楚ardupilot姿态控制为什么要用到四元数,欢迎批评指正!!! 阅读详情

相关推荐

MIMO技术入门

MIMO:多天线技术,发射端和接收端有多个天线(注意:并不是指多个天线板,而是多套振子,每一套是一个独立的天线。) 4G:2、8天线 5G:4、64天线(64T64R) 手机也是多天线 MIMO实现效果的分类: 1)空间分集 。2)空间复用。3)波束赋形。 空间分集(space diversity) 作用:提升接收质量 利用多个天线发射或者接收一个数据流,避免单个信道衰落对整个链路的影响。(比如你的耳机坏了一只并不影响另一只) 空间复用(space multiplexing) 作用:提升速率 利

About1129的博客 2875

hdu 4801 Pocket Cube(暴力)

题目链接:hdu 4801 Pocket Cube代码#include <cstdio> #include <cstring> #include <algorithm>using namespace std; const int maxn = 24; int rot[6][maxn] = {{6, 1, 12, 3, 5, 11, 16, 7, 8, 9, 4, 10, 18, 13, 14, 15

不慌不忙、不急不躁 820

切比雪夫(最小区域法)直线拟合算法

切比雪夫,最小区域法直线拟合

闪电彬彬的博客 3962

HDU 4801 Pocket Cube

题目链接 Pocket Cube Problem Description Pocket Cube is a 3-D combination puzzle. It is a 2 × 2 × 2 cube, which means it is constructed by 8 mini-cubes. For a combination of 2 × 2 mini-cubes which sharing...

weixin_43236122的博客 222

SIwave仿真手册——软件基础(一)

最近在学习SIWAVE,在这里将自己的笔记整理一下,做一个专题。希望对大家有帮助,这个会持续更新的。仅限于软件操作学习,不涉及信号完整性的讨论。

luohuo9844的博客 4万+

SQLSTATE58030

在优化一条SQL的时候遇到了执行错误 gtlions =# select t1.telnumber,t2.ua,t2.url,t1.apply_name,t2.apply_name from tb1 t1 gtlions -# left outer join tb2 t2 on t1.sid = t2.ipsid gtlions-# where t1.sum_date=20141128 a

Gtlions Tracker 3659

HDU 4801 Pocket Cube BFS

一个魔方在N次操作内,能有几面相同的问题

看曙光 1537

PCIe 6.0 – 关于 PCI Express Gen6 您需要知道的一切

幸运的是,PCIe 6.0 FEC 足够轻,对延迟的影响最小。在电气层上,PCIe 6.0 使用 PAM4 信号(“四级脉冲幅度调制”),每个时钟周期将 2 位组合为 4 个幅度级别(00、01、10、11),与 PCIe 5.0 和前几代相比,它使用 NRZ 调制,每个时钟周期 1 位和两个幅度级别 (0, 1)。虽然 PAM4 信号更容易出错,但由于调制技术的性质,与 PCIe 5.0 相比,通道损耗不受影响,因此 PCB 上 PCIe 6.0 信号的范围将与 PCIe 5.0 相同。

qq_43416206的博客 3431

HDU - 4801 Pocket Cube(魔方)

魔方问题

什么样的小孩 的博客 544

39、低功耗处理器性能评估与Cortex - M23/M33低功耗特性解析

本文深入解析了Cortex-M23和Cortex-M33处理器的低功耗特性及其性能评估方法。介绍了ULPMark、CoreMark、IoTMark-BLE和SecureMark-TLS等基准测试在能效评估中的应用,并详细阐述了处理器的睡眠模式、系统控制寄存器(SCR)配置、WFI/WFE指令、退出时睡眠、挂起时发送事件(SEVONPEND)以及唤醒中断控制器(WIC)等关键低功耗机制。结合状态保留技术,展示了如何通过芯片级设计大幅降低泄漏电流,实现高效能低功耗的物联网与嵌入式系统设计。

Pepper的专栏 129

[QMT量化交易小白入门]-四十四、年化收益48%的策略要兼容回测和实盘,将实盘改为定时任务的方式

本专栏主要是介绍QMT的基础用法,常见函数,写策略的方法,也会分享一些量化交易的思路,大概会写100篇左右。QMT的相关资料较少,在使用过程中不断的摸索,遇到了一些问题,记录下来和大家一起沟通,共同进步。

木头大左的博客 1369

HDU 4801 Pocket Cube (模拟)

题意: 给出一个2阶魔方,问在少于N步旋转内,最多产生多少个同样颜色的面? 思路: 共6个有效方向,模拟即可。 有一个坑点,颜色不是0-5的,是 Integer 。判重时注意下即可 代码: #include &lt;bits/stdc++.h&gt; using namespace std; int n, fans; int dirx[6][8] = { { 0,2,6,12,16,...

DT2131 567

lammps教程:in文件结构详解以及一个比较实用的in文件模板

lammps软件只是一个求解器,没有可视化的前处理和后处理软件,所有的命令只能通过代码的方式输入到求解器进行求解计算。 所有的命令都被写到一个称为“in”的文件里,对于初学者来说,熟悉in文件的编写是一个难点。 in文件其实就是一个文本文档,也没有要求文件名或者后缀名中必须带有“in”字样,用任何文件名均可运行。 in文件里的代码是按照编写的顺序进行解释执行,对于大部分命令行来说,前后顺序影响并不是很大,但是,对于一些命令,在执行过程中需要某个参数,则这个参数的定义和计算必须写在命令执行之前。 例如,对晶体

lammps_jiayou的博客 2万+

HDU 4801 Pocket Cube bfs

Pocket Cube Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 816    Accepted Submission(s): 255 Problem Description Pocket Cube is

We Can 592

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

HDU4801 Pocket Cube(恶心的模拟)

原题地址http://acm.hdu.edu.cn/showproblem.php?pid=4801 题意:给你一个2∗2∗22*2*22∗2∗2的魔方,问你旋转最多n次,可以还原最多几个面 思路:模拟就行了.一个魔方有3种旋转方式,2种旋转方向(顺时针和逆时针),所以对于每一步,你可以有6种方法取旋转,那么因为n&amp;amp;lt;=7n&amp;amp;lt;=7n&amp;lt;=7,所以暴力dfs就行了, #...

yiqzq的博客 449

深度学习工具包 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 4801 Pocket Cube(模拟题——转魔方)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4801 题面: Pocket Cube Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 882    Accepted

David_Jett 2279

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

hdu 4801 Pocket Cube 四面魔方,模拟+搜索

魔方只有4面,且深度只有7层,所以可以搜索解决。由于模拟过程复杂,干脆用一个辅助数组记录每次转动每个点的对应位置,在脑中空间想象一下就好了。 值得注意的一点是不需要模拟12次(6条边,顺+逆2次)因为一条边顺时针就相当于另一条边逆时针。 #include #include #include #include #include #include #include #include

1313

HDU 4801 2013 Changsha Regional Pocket Cube[大模拟]

题意: 2×2的魔方,给出初始状态,问7步之内最多能有几个面相同 本来是道大水题 但是,,, 心酸啊 一开始直接得到状态的hash,用bool vis来bfs,但是wa了,我以为不行,然后又用结构体哈希vis来bfs,然后还是WA,结果发现,,,魔方有6种转法,我只想到了4种。。。 然后改成6种,各种T各种MLE,再改回bool vis才过了 算了下,6^7=24W,然后我b

Rainto的专栏 971

HDU 4801 Pocket Cube(暴力模拟 dfs)

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

风尘_浪子 1274

Pocket Cube HDU - 4801 (dfs)

Pocket Cube is a 3-D combination puzzle. It is a 2 × 2 × 2 cube, which means it is constructed by 8 mini-cubes. For a combination of 2 × 2 mini-cubes which sharing a whole cube face, you can twist it 9

Coldfresh的博客 424

hdu 4801 Pocket Cube(dfs+模拟)

http://acm.hdu.edu.cn/showproblem.php?pid=4801题目大意: 现在有一个2*2*2的魔方,给出指定步数,问你在指定步数之内最多能还原几个面?解题思路: dfs搜6次,每次模拟7次,分别是前,左,上(各顺时针逆时针90度)#include<iostream> using namespace std; struct node{ int s[25];

HJ 468

ZOJ 3736 & HDU 4801 - Pocket Cube 打表搜索

题意:                         给了一个2*2的魔方..每步操作可以将任意一面翻转90度..现在问在N(                题解:                         开始自己打了个10行表..好难找错..然后发现..其实只要六个就行了..因为左侧正90转和右侧负90转时一样的..                         论科学打表.

zzyzzy12 1776

2013 ACM区域赛长沙 K Pocket Cube hdu 4801

题意:给了一个2*2的魔方..每步操作可以将任意一面翻转90度..现在问在N(<=7)步内.最多能翻出几面相同的. 直接打表模拟每种翻转情况 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 us...

weixin_30747253的博客 123

hdu4801 PocketCube 2阶魔方

http://acm.hdu.edu.cn/showproblem.php?pid=4801 1. 题目描述给定一个2×2×22×2×2的魔方,当某个面上的4个小块颜色均相同时,称这个面为complete。求对这个魔方进行n∈[1,7]n∈[1,7]次旋转(沿某个面顺时针或者逆时针)的过程中,求complete的面总和的最大值。魔方及索引如下图所示: 我一直以为魔方只有8种操作 上...

weixin_30607029的博客 171

2013区域赛长沙赛区现场赛 K - Pocket Cube

K -Pocket Cube Time Limit:10000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64u SubmitStatusPracticeHDU 4801 Description Pocket Cube is a 3-D combination puzzle. It ...

weixin_34405354的博客 132

UVa816 Abbott's Revenge

题意:走迷宫,在某个点,对于mou'g

A Cube Master 1929
上一篇: hdu 5014 Number Sequence
下一篇: hdu 4800 Josephina and RPG
squee_spoon
博客等级 码龄14年 61粉丝 455原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值