kuangbing带你飞 专题一 简单搜索题解

5个4000比特大状态置换算法的设计与分析 下面是 5 个概念性、实验性的 4000 位可逆置换设计。它们都保证是双射,但未经过密码分析,不可直接用于生产系统。风格分别覆盖:三维 SPN、Feistel、可逆元胞自动机、ARX、宽轨迹/Keccak 式结构。 这 5 个设计分别代表了 SPN、Feistel、元胞自动机、ARX、宽轨迹 Keccak 五种不同风格,覆盖了主流大状态置换的构造思路。再次强调:它们只是实验性概念,若要用于实际协议,必须经过严格安全性分析。 阅读详情

kuangbin带你飞 专题一 简单搜索

1. POJ 1321 棋盘问题

http://poj.org/problem?id=1321

题目类似八皇后 但是加入了障碍物 以及规则为不能同列和同行

我一开始的思路走入了误区 用bool二维数组判断标记

其实我们可以简化问题

将问题看做 在每一行选一个点落下棋子 而保证棋子不在一列 即可

由此确定出dfs的递归参数 一个是行 一个是棋子数 当超出行的时候回溯 在棋子数满足答案时res++并回溯

有一个值得注意的地方 在一行里 可以选择放 也可以选择不放 要注意写出在本行不放的递归函数

char g[10][10];
bool st[10];//这是列的标记 行不需要 因为我们是行行递推下去的
int res, n, k;
 
void dfs(int dep, int num)//第几行 落子数
{
   
   
    if(num == k)  {
   
   res ++; return;}

    if(dep > n)    return;//越界

    for(int j = 1; j <= n; j++)
    {
   
   
        if(g[dep][j] == '#' && !st[j])
        {
   
   
            st[j] = true;
            dfs(dep + 1, num + 1);//落子成功
            st[j] = false;
        }
    }
    dfs(dep + 1, num);//在本行没有选到位置落子
}

int main()
{
   
   
    while(scanf("%d%d", &n, &k) == 2)
    {
   
   
        if(n == -1 && k == -1)  break;
        res = 0;
        for(int i = 1; i <= n; i++)
            scanf("%s", g[i] + 1);

        ms(st, false);

        dfs(1, 0);//从第一行开始 初始落子数0

        printf("%d\n", res);
    }
    return 0;
}

2. POJ 2251 Dungeon Master

http://poj.org/problem?id=2251

这是一个三维地图 读入非常坑爹

反正我觉得题目不能很好地描述题意

思路就是简单的bfs 不过可以向上向下走

调了一下午bug 直接上代码吧

char g[35][35][35];
bool st[35][35][35];
int l, r, c;

int d[6][3]={
   
   {
   
   1,0,0},{
   
   -1,0,0},{
   
   0,1,0},{
   
   0,-1,0},{
   
   0,0,1},{
   
   0,0,-1}};//方向向量

struct point
{
   
   
    int x, y, z;
    int step;
};

bool check(int x, int y, int z)//判断合法
{
   
   
    if(x < 0 || y < 0 || z < 0 || x >= l || y >= r || z >= c ) return true;
    else if(st[x][y][z] == true) return true;
    else if(g[x][y][z] == '#')   return true;
    return false;
}

void bfs(int aa, int bb, int cc)
{
   
   
    queue<point> q;
    
    point start;
    start.x = aa, start.y = bb, start.z = cc, start.step = 0;
    q.push(start);
    st[aa][bb][cc] = true;

    while(q.size())
    {
   
   
        point t = q.front();
        q.pop();
        
        if(g[t.x][t.y][t.z] == 'E')//达到出口
        {
   
   
            cout<<"Escaped in "<< t.step <<" minute(s)."<<endl;
            return;
        }

        for(int i = 0; i < 6; i++)
        {
   
   
            int xx = t.x + d[i][0], yy = t.y + d[i][1], zz = t.z + d[i][2];
            if(check(xx, yy, zz))  continue;

            st[xx][yy][zz] = true;
            point tt;
            tt.x = xx, tt.y = yy, tt.z = zz;
            tt.step = t.step + 1;
            q.push(tt);
        }
    }
    cout << "Trapped!" << endl;
    return;
}

int main()
{
   
   
    while(cin >> l >> r >> c)
    {
   
   
        if(l == 0 && r == 0 && c == 0)  break;
        
        int aa, bb, cc;
        for(int i = 0; i < l; i++)
            for(int j = 0; j < r; j++)
            {
   
   
                cin >> g[i][j];//字符串读入
                for(int h = 0; h < c; h++)
                    if(g[i][j][h] == 'S')     aa = i, bb = j, cc = h;//起点
            }
        ms(st, false);
        bfs(aa, bb, cc);
    }
    return 0;
}

3. POJ 3278 Catch That Cow

http://poj.org/problem?id=3278

给出一个起点x 给出一个终点 牛有三种移动方式 前进一格 后退一格 前进x * 2

用BFS的思想可以实现

有一个小点要注意 当n和k的差距很大的时候 需要乘很多次再去回头

所以是有可能有数据会卡在k的很后面的 下面判断合法的时候要注意一下

const int N = 100010;
int dis[N];
bool st[N];

struct node
{
   
   
    int x, step;
};

queue<node> q;

void bfs(int x)
{
   
   
    node h;
    h.x = x, h.step = 0;
    ms(st, false);

    q.push(h);
    st[h.x] = true;
    
    while(q.size())
    {
   
   
        node t = q.front();
        q.pop();

        if(t.x == k)   
        {
   
   
            cout << t.step << endl;
            return;
        } 

        for(int i = 0; i < 3; i++)//枚举三种移动方式
        {
   
   
            int xx;
            if(i == 0)  xx = t.x + 1;
            else if(i == 1) xx = t.x - 1;
            else if(i == 2) xx = t.x * 2;

            if(xx >= 0 && xx <= N && !st[xx])//之前错的是 xx <= k + 10 考虑不周
            {
   
   
                node next;
                next.x = xx, next.step = t.step + 1;
                q.push(next);
                st[xx] = true;
            }
        }
    }
}

int main()
{
   
   
    cin >> n >> k;
    bfs(n);
    return 0;
}

4. POJ 3279 Fliptile

http://poj.org/problem?id=3279

是蓝书中的改编版 同样的二进制枚举翻转牌子 但是这题要我们输出的是翻转过的位置 并且还是按字符串的字典序

二维矩阵压缩到字符串的话 这跟二进制枚举字典序其实是一样的 因为二进制枚举是先枚举第一个点翻转 然后

用ans数组记录下翻转的位置 当第一次翻转成功就break直接输出ans数组

如果没有一次翻转成功的话 IMPOSSIBLE

每次枚举的时候要记得清空ans数组 要用一个数组复制原数组翻转 是为了回溯

int m, n, flag;//地图 标记
int g[20][20], b[20][20], ans[20][20];
int d[5][2] = {
  
  {0, 0}, {1, 0}, {-1, 0}, {0, 1}, {0, -1}};

void turn(int x, int y)//把0 变成1 把1 变成0
{

    for(int i = 0; i < 5; i++)
    {
        int xx = x + d[i][0], yy = y + d[i][1];z	
        if(~xx && ~yy && xx < n && yy < m) b[xx][yy] ^= 1;
    }
}

bool check()//通过最后一行判断是否翻转完成
{
    for(int i = 0; i < m; i++)
        if(b[n - 1][i] == 1)   return false;
    return true;
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++) 
        for(int j = 0; j < m; j++)
            cin >> g[i][j];
    
    for(int i = 0; i < (1 << m); i++)//二进制枚举
    {
        memcpy(b, g, sizeof g);
        ms(ans, 0);

        for(int j = 0; j < m; j++)  
            if( i >> j & 1) turn(0, j), ans[0][j] = 1;//枚举第一行
        
        for(int j = 0; j < n - 1; j++)
            for(int k = 0; k < m; k++)  if(b[j][k]) turn(j + 1, k), ans[j + 1][k] = 1;
        
        if(check())
        {
            flag = 1;
            break;
        }
    }

    if(flag)
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
                cout << ans[i][j] << " ";
            cout << endl;
        }
    }
    else    cout << "IMPOSSIBLE" << endl;

    return 0;
}

5. POJ 1426 Find The Multiple

http://poj.org/problem?id=1426

翻译一下这个让人看不懂的题干

给定正整数n 请找出任意一个由0和1组成的是n的倍数的数 答案最大不超过200位数

看起来很吓人 其实不会超出LL的范围 那我们直接枚举这个二进制数 判断是否为n的倍数即可

LL ans[1000000];

int main()
{
   
   
    int n;
    while(cin >> n)
    {
   
   
        if(n == 0)  break;
        if(n == 1)  {
   
   cout << "1" << endl;continue;}
        ans[1] = 1;
        for(int i = 2; i; i++)
        {
   
   
            ans[i] = ans[i / 2] * 10 + i % 
学Simulink——基于直流电机的建模与控制场景实例:直流电机带负载突变时的动态响应仿真 在实际应用中,直流电机经常需要应对各种工作条件的变化,例如负载突变。了解电机在这种情况下的动态响应特性对于确保系统的稳定性和可靠性至关重要。通过仿真分析,可以预测电机在不同负载条件下的表现,并优化控制系统的设计。本文将详细介绍如何使用来构建一个直流电机带负载突变时的动态响应仿真模型,并通过仿真展示其应用效果。本文介绍了如何使用构建一个直流电机带负载突变时的动态响应仿真模型,并通过仿真展示了其应用效果。 阅读详情

相关推荐

别再折腾老教程了!树莓派4B/5最新系统(Raspberry Pi OS Bookworm)红外遥控配置,用gpio-ir驱动一次成功

本文详细介绍了树莓派4B/5在最新Raspberry Pi OS Bookworm系统下配置红外遥控的完整指南,摒弃过时的lirc-rpi驱动,采用现代gpio-ir驱动方案。从硬件连接到软件配置,提供10分钟快速上手指南,涵盖驱动加载、信号测试、按键映射及高级应用场景,帮助用户高效完成红外遥控配置。

weixin_42520909的博客 442

Win10更新后黑屏只剩鼠标?火绒误杀explorer.exe的5种自救方案(附详细步骤)

本文详细介绍了Win10更新后出现黑屏只剩鼠标的5种专业修复方案,重点解决火绒误杀explorer.exe的问题。从基础的任务管理器操作到安全模式下的系统修复,再到注册表编辑和系统还原,提供了全面的解决方案,帮助用户快速恢复系统正常运行。

weixin_29306571的博客 636

MATLAB实战:手把手教你绘制发动机万有特性曲线(附完整代码)

本文提供了一份详细的MATLAB实战指南,手把手教你从发动机台架试验数据出发,通过数据预处理、核心插值算法和可视化技巧,绘制出专业、精确的发动机万有特性曲线图。文章深入解析了万有特性图的核心构成与工程意义,并附带了完整的模块化代码,帮助工程师和学生快速掌握这一关键技能。

weixin_29094539的博客 410

保姆级教程:手把手带你复现APFNet论文的RGBT目标跟踪模型(附完整代码与数据集配置)

本文提供了一份详细的APFNet论文复现指南,涵盖从环境搭建到模型测试的全流程。通过解析多模态融合模块和渐进式训练流程,帮助读者高效完成RGBT目标跟踪模型的复现工作,特别针对训练和测试中的常见问题提供实用解决方案。

weixin_29056781的博客 341

2023华为OD面试手撕真题【最长公共前缀】

2023华为OD面试手撕真题【最长公共前缀】

MISAYAONE的博客 5235

为什么先进工艺需要check那么多corner?

那么hold slack = launch clock path delay + data path delay - capture_clock_path_delay = -capture_clock_path_delay,也就是说,capture clock path delay越大,hold越难满足。而且,我们在设计的时候,一般clock频率都会过约,所以是有较大的margin的。有的foundry还会对rc的取值范围进行了约束,如cworst_T,采用的是1.5 sigma的取值范围。

芯冰乐 2084

【即插即用模块】注意力篇 | TGRS 2025 | ASD:自适应频域解耦,动态拆分高低频+空间注意力,频域空间特征双增强!

摘要: FDMF-Net提出了一种频域解耦多模态融合网络,核心组件为振幅谱解耦模块(ASD)。ASD通过自适应频域拆分和频域-空域协同增强,有效分离模态不变与模态特定特征。该模块利用MLP学习动态阈值调整高低频比例,并通过空间注意力分别强化频域特征,在遥感语义分割任务中实现了细节与结构的协同增强。实验表明,ASD模块能减少模态内冗余,提升特征判别性,为多模态数据融合提供了新思路。代码已开源,适用于需要强化细节与结构的视觉任务。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 304

嵌入式硬件中AI硬件设计方法与技巧

嘉立创EDA推出AI助手Kimi插件,为PCB设计提供智能支持。该插件具备四大核心功能:AI问答助手可解答各类电路设计问题;元件查询功能直接展示参数和应用场景;智能分析网表可检测潜在问题;电路图识别能解析图纸结构并提供改进建议。用户需通过扩展插件安装,并配置Kimi API密钥后使用。该工具旨在提升工程师的设计效率,减少查阅资料时间,特别适合项目交接和设计自查场景。

嵌入式技术开发 1862

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

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

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

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

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

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

上一篇: CF #764 Div.3(B ~D)
下一篇: CF#771 Div.2 A~C 题解
a simple_boy
博客等级 码龄5年 1粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值