The Sultan's Successors UVA - 167

【实战解析】RTL8306MB交换芯片驱动开发中的RMII接口调试陷阱 本文深入剖析了RTL8306MB交换芯片驱动开发中RMII接口的典型调试陷阱。通过一个工业网关项目的实战案例,揭示了因硬件原理图设计疏忽导致TX_EN与CRS_DV信号线错接,从而引发网络“哑火”的根本原因。文章详细展示了使用示波器从时钟、数据到控制信号的系统性排查方法,并总结了关键的设计警示与自查清单,为嵌入式网络开发中的软硬件协同调试提供了宝贵经验。 阅读详情

//很久以前做的了,当时WA,一直没找到错误...然后今天看了下。。。发现就是每次开始新一轮年的时候没哟初始化.......

The Sultan of Nubia has no children, so she has decided that the country will be split into up to k separate parts on her death and each part will be inherited by whoever performs best at some test. It is possible for any individual to inherit more than one or indeed all of the portions. To ensure that only highly intelligent people eventually become her successors, the Sultan has devised an ingenious test. In a large hall filled with the splash of fountains and the delicate scent of incense have been placed k chessboards. Each chessboard has numbers in the range 1 to 99 written on each square and is supplied with 8 jewelled chess queens. The task facing each potential successor is to place the 8 queens on the chess board in such a way that no queen threatens another one, and so that the numbers on the squares thus selected sum to a number at least as high as one already chosen by the Sultan. (For those unfamiliar with the rules of chess, this implies that each row and column of the board contains exactly one queen, and each diagonal contains no more than one.) Write a program that will read in the number and details of the chessboards and determine the highest scores possible for each board under these conditions. (You know that the Sultan is both a good chess player and a good mathematician and you suspect that her score is the best attainable.) Input Input will consist of k (the number of boards), on a line by itself, followed by k sets of 64 numbers, each set consisting of eight lines of eight numbers. Each number will be a positive integer less than 100. There will never be more than 20 boards. Output Output will consist of k numbers consisting of your k scores, each score on a line by itself and right justified in a field 5 characters wide. Sample Input 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 48 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 Sample Output 260

 

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include <iomanip>
using namespace std;
int n=8, sum=0, msum=0;
int a[10][10] = { 0 }, b[10][10];
int t = 1;
void print()
{
    printf("No. %d\n", t++);
    for (int i = 0; i < 8; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            printf("%d ", a[j][i]);
        }
        printf("\n");
    }
}
bool judge(int x, int y)
{
    for(int i=0; i<x; i++)
    {//竖直方向||左上方 || 右上方
        if(a[i][y] || (y-i-1>=0 && a[x-i-1][y-i-1]) || (y+i+1<8 && a[x-i-1][y+i+1]))
            return false;
    }
    return true;
}
/*
void dfs(int num)
{
    if (num >= 8){
        print();
    }
    for (int i = 0; i < 8; i++)
    {
       if (a[num][i]!=1&&judge(num, i))
        {
            a[num][i] = 1;
            dfs(num + 1);
            a[num][i] = 0;
        }
    }
}
*/

int dfs(int num)
{
    if (num >= 8){
        //      print();
        if(msum < sum)
            msum = sum;
    }
    for (int i = 0; i < 8; i++)
    {
        if (a[num][i]!=1&&judge(num, i))
        {
            a[num][i] = 1;
            sum += b[num][i];
            if(dfs(num + 1))
            {  return 1;}
            a[num][i] = 0;
            sum -= b[num][i];
        }

    }
    return 0;
}
int main()
{

    int n;

    cin >> n;

    for(int k = 0; k < n; k++) {

        for (int i = 0; i < 8; i++)

            for (int j = 0; j < 8; j++)
                cin >> b[i][j];
        dfs(0);
        cout << fixed << setw(5) << msum << endl;
    }

        return 0;
}

 

Qt C++ HTTP 调用通义千问大模型 X 学术论文润色工具(SCI 格式适配) 请求地址:`https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation`;| Windows | 打包时携带 `Qt6Network.dll`/`libcrypto-1_1-x64.dll` 等依赖;| Linux | 安装 `libssl-dev` 和 `libcurl4-openssl-dev`;| API 调用失败 | 检查 API-KEY 是否有效; 阅读详情

相关推荐

几款支持国标GB28181的平台以及视频监控设备接入的配置方法(Web端无插件播放)

GB28181解决的一个主要问题就是如何远程、跨网络、跨区域、跨级别的访问网络中的监控设备(包括IPC、NVR等),本文介绍几款G28181平台的接入配置方法,适合有监控视频摄像头的远程接入和预览需求的人群参考使用。

一名高级工程师的博客 1万+

UVA_167_The Sultan's Successors

简单的八皇后   #include #include #include //using namespace std; int queen[8]; int a[8][8]; int ans; void dfs(int cur, int score) { if (cur == 8) { if (score > ans)ans =

Kizuki 576

HyperMesh实战:5种复杂载荷场景下的field映射技巧(附TCL脚本)

本文详细介绍了HyperMesh在5种复杂载荷场景下的field映射技巧,包括轴承载荷的圆柱坐标系映射、粉末压力中的切向力处理、实验数据到有限元模型的场映射、多工况载荷的组合映射以及局部细化网格的边界条件传递。通过实战案例和TCL脚本,帮助工程师高效解决有限元分析中的载荷映射难题,提升工作效率。

fanta的博客 294

UVa 167 The Sultan's Successors (八皇后问题)

167 - The Sultan's Successors Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_problem&problem=103 The Sultan of Nubia has n

AC,∑ndless 1608

PSO算法介绍

结合网上的文章对PSO进行一些介绍,并附上自己复现的算法。

Witty_Hou的博客 1万+

Windows下CMake的下载与安装详解

目录一、CMake介绍二、CMake的下载与安装 一、CMake介绍 CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。它能够输出各种各样的makefile或者project文件,能测试编译器所支持的C++特性,类似UNIX下的automake。 二、CMake的下载与安装 CMake下载链接:https://cmake.org/download/。 下载最新稳定版即可(Latest Release): 下载完成后,单击“Next”按钮,在下图中勾选“I acce

Wendy的博客 8万+

UVa 167 - The Sultan's Successors

/* 八皇后问题两种方法实现,参考《算法竞赛入门经典》 */ #include #include #include using namespace std; const int MAX = 8; const int RESULT = 100; int row[MAX]; int save[RESULT][MAX]; int cur = 0; int m[MAX][MAX]; int

cugfjp的专栏 470

基于STM32设计的智能门锁(微信小程序+手机APP等多种方式开锁)(188)

当前智能门锁项目是基于STM32微控制器、ESP8266-WIFI模块、OLED显示屏、指纹模块、蓝牙模块、门禁刷卡模块、烟雾检测模块、火光检测模块、温湿度检测模块等硬件设备开发的一种智能门锁系统

1万+

uva 167 - The Sultan's Successors

The Sultan's Successors  The Sultan of Nubia has no children, so she has decided that the country will be split into up to k separate parts on her death and each part will be inherited by

uva code 1558

SAP_MM&FI模块-质保金标准解决方案详解

主要讲述了SAP系统质保金的标准实现方案,包含业务背景、后台配置、前台业务操作记录,以及关键点的AI解释;

风沙的博客 685

SAP GR(Group Reporting)配置篇(五)

1.5、合并的货币换算1.5.1指定折算比率菜单路径组报表的SAP S4HANA >合并的货币换算>-指定折算汇率事务代码GCRF说 明1.5.2维护汇率菜单路径组报表的SAP S4HANA >合并的货币换算>维护汇率事务代码CXCC/OB08说 明实际测试的时候根据实际情况维护汇率。输入换算比率。1.5.3定义汇率标识符菜单路径组报表的SAP S4HANA >合并的货币换算>定义汇率标识符事务代码OC41说 明配置了月末汇率和平均汇率。

weixin_43853754的博客 554

uva 167 - The Sultan's Successors(典型的八皇后问题)

这道题是典型的八皇后问题,刘汝佳书上有详细的讲解。代码的实现如下: #include #include #include int vis[100][100];//刚开始wrong的原因就是这里数组开小了,开了[8][8],以为能够。后来看到[cur-i+8]意识到可能数组开小了,改大之后AC。 int a[8][8]; int C[10]; int max_,tot; void sea

GejinZ 1582

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

UVa 167 - The Sultan's Successors(2)

/* File: 167.cpp Author: ACboy Date: 2010-3-25 Result: 1A Description: UVa 167 - The Sultans Successors*/#include using namespace std;int data[10][10];int viscolumn[10];int

个人独立博客http://www.acb0y.cn/ 1357

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

VC中sqlite的使用

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

UVA 167,The Sultan's Successors

题目:八皇后问题的基础上输入每个格子上的数值。问哪一组数的和最小 #include #include #include #include #include #include #include #include using namespace std; int main() {  

脚踏实地 275

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

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

UVA 167 The Sultan's Successors

UVA 167 The Sultan’s Successors题目大意:类八皇后问题,每个格子都有权值 解题思路:回溯#include <stdio.h> #include <iostream> #include <string.h> using namespace std; int num[9][9]; int ju[3][20]; int s; int p; void dfs(int a) {

ZeroLH00的博客 638

uva167 The Sultan's Successors

Accepted 0ms

keshuqi的博客 594

Uva 167 The Sultan's Successors(dfs)

题目链接:Uva 167 思路分析:八皇后问题,采用回溯法解决问题。 代码如下: #include <iostream> #include <string.h> using namespace std; const int MAX_N = 10; int A[MAX_N]; int M[MAX_N][MAX_N]; int num,...

aqjh9999的博客 110

uva 167 The Sultan's Successors(回溯)

The Sultan's Successors  The Sultan of Nubia has no children, so she has decided that the country will be split into up to k separate parts on her death and each part will be inherited

不慌不忙、不急不躁 2338

UVA 167 The Sultan's Successors

UVA-167题意:八皇后问题升级版,在有值的8×8矩阵上放置八皇后,求最大值。 解题思路:八皇后问题,多一个记录总和sum,取最大值。/************************************************************************* > File Name: UVA-167.cpp > Author: Narsh >

QzNarsh的博客 447

uva 167 The Sultan's Successors

题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_problem&problem=103 题目描述: The Sultan's Successors  The Sultan of Nubia h

心之所向,无惧无悔! 1226

uva 167 The Sultan's Successors 搜索

入门经典

禅境花园 456
上一篇: Red and Black POJ - 1979
下一篇: 8 Queens Chess Problem UVA - 750 (很久之前WA,,然后 现在改了一点之后 PE,,又改了一会A了)
KLFTESPACE
博客等级 码龄9年 66粉丝 655原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值