JXUFE紫书第四章习题 A 4-1

异常检测论文阅读《Anomaly Detection in Video Sequences: A Benchmark and Computational Model》 CVPR2021异常检测的的论文,里面提出了新的异常检测数据集 阅读详情

考虑一个象棋残局,其中红方有n(2≤n≤7)个旗子,黑方只有一个将。红方除了有一个帅(G)之外还有3种可能的棋子:车(R),马(H),炮(C),并且需要考虑“蹩马腿”与将和帅不能照面(将、帅如果同在一条直线上,中间又不隔着任何棋子的情况下,先走的一方获胜)的规则。

输入所有棋子的位置,保证局面合法并且红方已经将军。你的任务是判断红方是否已经把黑方将死。关于中国象棋的相关规则请参见原题。

原题描述

Description

Xiangqi is one of the most popular two-player board games in China. The game represents a battle between two armies with the goal of capturing the enemy’s “general” piece. In this problem, you are given a situation of later stage in the game. Besides, the red side has already “delivered a check”. Your work is to check whether the situation is “checkmate”.

Now we introduce some basic rules of Xiangqi. Xiangqi is played on a 10×9 board and the pieces are placed on the intersections (points). The top left point is (1,1) and the bottom right point is (10,9). There are two groups of pieces marked by black or red Chinese characters, belonging to the two players separately. During the game, each player in turn moves one piece from the point it occupies to another point. No two pieces can occupy the same point at the same time. A piece can be moved onto a point occupied by an enemy piece, in which case the enemy piece is “captured” and removed from the board. When the general is in danger of being captured by the enemy player on the enemy player’s next move, the enemy player is said to have “delivered a check”. If the general’s player can make no move to prevent the general’s capture by next enemy move, the situation is called “checkmate”. 

We only use 4 kinds of pieces introducing as follows: 

General: the generals can move and capture one point either vertically or horizontally and cannot leave the “palace” unless the situation called “flying general” (see the figure above). “Flying general” means that one general can “fly” across the board to capture the enemy general if they stand on the same line without intervening pieces. 

Chariot: the chariots can move and capture vertically and horizontally by any distance, but may not jump over intervening pieces 

Cannon: the cannons move like the chariots, horizontally and vertically, but capture by jumping exactly one piece (whether it is friendly or enemy) over to its target. 

Horse: the horses have 8 kinds of jumps to move and capture shown in the left figure. However, if there is any pieces lying on a point away from the horse horizontally or vertically it cannot move or capture in that direction (see the figure below), which is called “hobbling the horse sleg”.

Now you are given a situation only containing a black general, a red general and several red chariots, cannons and horses, and the red side has delivered a check. Now it turns to black side’s move. Your job is to determine that whether this situation is “checkmate”.

Input

The input contains no more than 40 test cases. For each test case, the first line contains three integers representing the number of red pieces N (2<=N<=7) and the position of the black general. The following n lines contain details of N red pieces. For each line, there are a char and two integers representing the type and position of the piece (type char ‘G’ for general, ‘R’ for chariot, ‘H’ for horse and ‘C’ for cannon). We guarantee that the situation is legal and the red side has delivered the check. 

There is a blank line between two test cases. The input ends by 0 0 0.


样例输入和样例输出:


#include <iostream>
#include <cctype>
#include <memory.h>
using namespace std;


char chess[11][10];//棋盘


const int movH[8][2] = {{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1},{-2,1}};//馬的走位


//棋子
struct Chess
{
    char type;
    int x;
    int y;
};


//由馬的走位推出“馬脚”的位置
int isMove (int i)
{
    if(i > 0)
        return -1;
    else if (i < 0)
        return 1;
    else
        return 0;
}


//帥的攻击路线
bool G (int x, int y, int target_x, int target_y)
{
    int i;
    if (y != target_y)//如果帥与目标不在同一纵轴上,则必定无法攻击成功
        return false;
    //将的攻击路线上是否有别的棋子
    for (i = x-1; i > target_x; i--)
        if (isalpha(chess[i][y]))
            return false;
    return true;
}


//車的攻击路线
bool R (int x, int y, int target_x, int target_y)
{
    int i;
    if (x != target_x && y != target_y)
        return false;
    else
    {
        //按照車在敌方将的上下左右四个位置有不同的攻击路线(炮也一样)
        if (x == target_x)
        {
            if (y < target_y)//車在将的左边
                for (i = y+1; i <= target_y; i++)
                {
                    if (isalpha(chess[x][i]))
                        return false;
                    else
                        continue;
                }
            else if (y > target_y)//車在将的右边
                for (i = y-1; i >= target_y; i--)
                {
                    if (isalpha(chess[x][i]))
                        return false;
                    else
                        continue;
                }
        }
        else if (y == target_y)
        {
            if (x < target_x)//車在将的上方
                for (i = x+1; i <= target_x; i++)
                {
                    if (isalpha(chess[i][y]))
                        return false;
                    else
                        continue;
                }
            else if (x > target_x)//車在将的下方
                for (i = x-1; i >= target_x; i--)
                {
                    if (isalpha(chess[i][y]))
                        return false;
                    else
                        continue;
                }
        }
    }
    return true;
}


//馬的攻击路线
bool H (int x, int y, int target_x, int target_y)
{
    int i;
    for (i = 0; i < 8; i++)
        if (x+movH[i][0] == target_x && y+movH[i][1] == target_y)
            if (!isalpha(chess[i+isMove(movH[i][0])][i+isMove(movH[i][1])]))//“馬脚”处是否有棋子
                return true;
    return false;
}


//炮的攻击路线
bool C (int x, int y, int target_x, int target_y)
{
    int i,cnt = 0;
    if (x != target_x && y != target_y)
        return false;
    else
    {
        if (x == target_x)
        {
            if (y < target_y)
                for (i = y+1; i <= target_y; i++)
                {
                    if (isalpha(chess[x][i]))
                        cnt++;
                    else
                        continue;
                }
            else if (y > target_y)
                for (i = y-1; i >= target_y; i--)
                {
                    if (isalpha(chess[x][i]))
                        cnt++;
                    else
                        continue;
                }
        }
        else if (y == target_y)
        {
            if (x < target_x)
                for (i = x+1; i <= target_x; i++)
                {
                    if (isalpha(chess[i][y]))
                        cnt++;
                    else
                        continue;
                }
            else if (x > target_x)
                for (i = x-1; i >= target_x; i--)
                {
                    if (isalpha(chess[i][y]))
                        cnt++;
                    else
                        continue;
                }
        }
    }
    if (cnt == 1)//炮与攻击目标之间有且只有一个棋子才能攻击成功
        return true;
    else
        return false;
}


//红方所有棋子分别对目标位置进行攻击
bool isKill (Chess* p, int n, int target_x, int target_y)
{
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i].type == 'G')
        {
            if (G(p[i].x, p[i].y, target_x, target_y))
                cnt++;
        }
        else if (p[i].type == 'R')
        {
            if (R(p[i].x, p[i].y, target_x, target_y))
                cnt++;
        }
        else if (p[i].type == 'C')
        {
            if (C(p[i].x, p[i].y, target_x, target_y))
                cnt++;
        }
        else if (p[i].type == 'H')
        {
            if (H(p[i].x, p[i].y, target_x, target_y))
                cnt++;
        }
        else
            continue;
    }
    if (cnt && !isalpha(chess[target_x][target_y]))
        return true;
    else if (isalpha(chess[target_x][target_y]) && cnt > 1)//若黑方将的下一步会吃掉红方一棋子(不包括将与帥之间的攻击),那么红方必须有其他棋子能成功进行下一步攻击
        return true;
    else
        return false;
}


int main (void)
{
    char c;
    int n,t_x,t_y;
    while ((cin >> n >> t_x >> t_y) && n && t_x && t_y)
    {
        memset(chess, '*', sizeof(chess));
        Chess* p = new Chess[7];
        chess[t_x][t_y] = 'g';
        int i,x,y;
        for (i = 0; i < n; i++)
        {
            cin >> c >> x >> y;
            chess[x][y] = c;
            p[i].type = c;
            p[i].x = x;
            p[i].y = y;
        }


        bool way1 = true, way2 = true, way3 = true, way4 = true;
        //先对帥的位置进行判断,如果将与帥处于可以互相攻击的位置,那么红方必输
        for (i = 0; i < n; i++)
            if (p[i].type == 'G')
                if (G(p[i].x, p[i].y, t_x, t_y))
                {
                    cout << "NO\n";
                    return 0;
                }
        //对黑方"将"所有可行的下一步棋进行模拟攻击
        if (t_x-1 >= 1)
        {
            way1 = false;
            if (isKill(p, n, t_x, t_y-1))
                way1 = true;
        }
        if (t_x+1 <= 3)
        {
            way2 = false;
            if (isKill(p, n, t_x, t_y+1))
                way2 = true;
        }
        if (t_y-1 >= 4)
        {
            way3 = false;
            if (isKill(p, n, t_x-1, t_y))
                way3 = true;
        }
        if (t_y+1 <= 6)
        {
            way4 = false;
            if (isKill(p, n, t_x+1, t_y))
                way4 = true;
        }
        if (way1 && way2 && way3 && way4)
            cout << "YES\n";
        else
            cout << "NO\n";
        delete []p;
    }
    return 0;
}



Python 实现生命游戏及进化模拟完整指南 生命模拟是进化计算的一个特定子集,模拟了自然界中所观察到的自然过程,例如粒子或鸟群的聚集方式。生命模拟只是用来探索和优化问题的模拟形式之一,还有很多其他形式的模拟,可以更好地建模各种过程,但它们都源于康威生命游戏 (Conway’s Game of Life)。在本节中,我们将介绍生命模拟的基本概念,并使用 Python 实现康威生命游戏。 阅读详情

相关推荐

代码生成 | 安时积分法模型搭建

安时积分法是电池电量计量最基础的方法,今天我们用simulink建模的方式做一个安时积分模型,从而更好地理解安时积分的思想也掌握建模的基础操 ​新建文件 打开MATLAB启动simulink新建一个模型文件 定义变量 和手写代码一样,先定义几个后面要用到的变量,在simulink建模时新建变量用Data Store Memory模块。双击填入要定义的变量名,然后在signal attributes赋初值 如此方法新建四个变量current(电流)初值1000mA、tatol_cap(总容量

ningvay的博客 1万+

紫书第6章 数据结构基础 例题(E-H)

数据结构基础 例题E-HH-TreeG-Trees on the levelF- Dropping BallsE-Self-Assembly H-Tree Description You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary tree to any leaf

qq_52508038的博客 3972

第七章-分布式搜索引擎-ES:全文查询、分词查询、精确查询、地理坐标查询、组合查询(bool、funtion_score)以及RestApi

111

weixin_36580930的博客 1632

第四章习题 4-1

考虑一个象棋残局,其中红方有n(2≤n≤7)个棋子,黑方只有一个将。红方除了有一个 帅(G)之外还有3种可能的棋子:车(R),马(H),炮(C),并且需要考虑“蹩马 腿”(如图4-4所示)与将和帅不能照面(将、帅如果同在一条直线上,中间又不隔着任何棋 子的情况下,走子的一方获胜)的规则。 输入所有棋子的位置,保证局面合法并且红方已经将军。你的任务是判断红方是否已经 把黑方将死。关于中国象棋的相关规...

weixin_42193704的博客 690

Qt开发中彻底解决中文乱码问题

中文乱码问题主要源于编码不一致需要同时设置控制台和Qt应用程序的编码确保项目文件和环境配置的编码一致文件操作时注意指定正确的编码。

qq_53832058的博客 3404

阿里云学生机2核4G,30分钟搞定DNF台服联机(CentOS 7.6保姆级教程)

本文提供阿里云学生机2核4G搭建DNF台服联机的详细教程,涵盖服务器选购、网络配置、服务端部署及客户端联机设置。通过CentOS 7.6系统优化和端口配置,30分钟内即可完成搭建,适合学生和技术爱好者低成本实现游戏联机体验。

weixin_42537919的博客 359

UVa1589 象棋

大一新生,欢迎各位大佬评论提出宝贵意见,觉得对你有用的话点个赞吧! 也可以评论一下想看的题目,我可以去试试 ^v^

qq_62306969的博客 831

gmsv源代码c语言,石器时代ABLua的原理、简介、过程、运用、收发

操作原理(一)服务端:服务器源文件客户端:客户所操作的程序(既是游戏客户端)接口:既是某项功能(例如:鼠标点击,文字发送,战斗,观战,人物动作等)返回的值ABlua:在源代码中添加的整套引擎作为回调接口--lua所实现的功能是基于服务端源码添加的接口由该接口与客户端发送封包实现功能源码里是否有ABlua回调接口?例如:源码里的gmsv/battle.c文件(既是战斗回调文件)以下为简单描述C给予l...

weixin_35223575的博客 2408

刷紫书第四章例题(例题4-1,4-2,4-3)

例题4-1 Ancient Cipher UVA - 1339 Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces a

ccnuacmhdu的博客 544

【同等学力】2025-数学✨

本文主要涵盖了谓词逻辑、集合论、图论和排列组合等多个数学领域的题目。在谓词逻辑部分,要求用全称量词和存在量词表达“没有两个人的指纹完全相同”。集合论部分涉及集合运算的证明,如证明(A-B)-C=(A-C)-(B-C)。图论部分包括计算给定10个点的联通图的边与面数。排列组合部分则要求计算从8个人中选6个并分为三组的不同方法。此外,还涉及偏序、长链、反链、二项式定理等相关内容,参考了多个优快云博客中的解题思路。

super_mochi1 679

k8s上分离集群seatunnel部署(生产推荐)

k8s上分离集群seatunnel部署(生产推荐)

寂夜了无痕的博客 888

刘汝佳《算法竞赛入门经典(第二版)》习题(六)

刘汝佳《算法竞赛入门经典(第二版)》第四章习题(4-1~4-3) 习题4-1 象棋(Xiangai,ACM/ICPC Fuzhou 2011,UVa1589) 考虑一个象棋残局,其中红方有n(2≤n≤7)个旗子,黑方只有一个将。红方除了有一个帅(G)之外还有3种可能的棋子:车(R),马(H),炮(C),并且需要考虑“蹩马腿”与将和帅不能照面(将、帅如果同在一条直线上,中间又不隔着任何棋

程序人生 1903

Multisim14使用教程详尽版--(2025最新版)

摘要:本文详细介绍了Multisim14电路仿真软件的功能和使用方法。主要内容包括:1)主流电路仿真软件比较,突出Multisim在教学、竞赛设计中的优势;2)软件界面说明,涵盖菜单栏、工具栏、元器件库和仪器仪表;3)18类元器件分类详解及其使用操作;4)15种仪器仪表的原理和应用场景;5)电路原理图设计与仿真流程;6)基本电路分析方法(直流静态工作点分析、交流分析等)。文章还提供了硬件工程师笔试面试相关资源链接,涵盖电阻、电容、三极管等器件知识及AD软件操作指南。通过系统讲解,帮助用户掌握Multisim

XU157303764的博客 2万+

JXUFE紫书第四章习题4-7

原题描述:RAID (Redundant Array of Inexpensive Disks) is a technique which uses multiple disks to store data.By storing the data on more than one disk, RAID is more fault tolerant than storing data on a si...

JXUFE_ACMer的博客 299

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

JXUFE紫书第四章习题4-10

英文题目:To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provides clients withthe elevation of each 10-meter by 10-meter square of land in regions where homes may be purch...

JXUFE_ACMer的博客 325

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

JXUFE紫书第四章习题 D 4-4

题目大意:将第二个骰子旋转,判断是否能与第一个骰子各面颜色完全相同。思路:将1号位固定,共有6种可能,且此时6号位也已固定;再将2号位固定,有4种可能,此时剩下的面颜色都已固定;所以一共有24种可能。...

JXUFE_ACMer的博客 283

JXUFE紫书第四章习题 4-8

题意:每个学生(1&lt;=n&lt;=10)存在一个awake-sleep周期,当这个学生到awake的最后一刻时,他要判断当前睡觉和醒的学生的人数,如果睡觉的人数绝对大于醒着的人数,那么他要继续保持清醒a分钟,否则就进入睡觉状态。给出n个学生的清醒周期和睡觉周期以及初始时刻处于周期的时刻,判断什么时刻全班同学都清醒着,如果不存在这样的时刻,那么就输出-1.分析:只需要计算每个时刻全班的清醒人数...

JXUFE_ACMer的博客 266

JXUFE紫书第四章习题 C 4-3

#include &lt;stdio.h&gt;#include &lt;string.h&gt; const int maxn=10;char board[maxn][maxn];//棋盘信息int legal[maxn][maxn]; //落子合法位置int direction[maxn];//八个方向,"米"字形,重左横开始,顺时针方向。void printdirection(){    i...

JXUFE_ACMer的博客 279

JXUFE紫书第四章习题 E 4-5

Alex is administrator of IP networks. His clients have a bunch of individual IP addresses and he decided to group all those IP addresses into the smallest possible IP network.Each IP address is a 4-by...

JXUFE_ACMer的博客 212

JXUFE紫书第四章习题B 4-2

#include&lt;iostream&gt;using namespace std;int a[10][10];int b[10][10];int judge (int len, int n)  {      int sum = 0, num = n/len;      for (int i = 1; i &lt; num+1; i++)          for (int j = 1; j ...

JXUFE_ACMer的博客 211

JXUFE紫书第三章例题 Prime Factors

int ms =(int)sqrt(2^31-1)+1;cin&gt;&gt;x;//x 是输入的数0.打表1.不用保存大于 ms 的素数,后期绕晕了。 记得筛选素数的时候到i*i&lt;=x就行了。2.不能直接判断x是不是在isprime里面,否则会造成RE,因为isprime[x&gt;ms]会造成数组越界。3.有时候直接判断特殊情况可以减少工作量,但会牺牲代码简洁性(便于查错)。4.细节处理...

qq_40822492的博客 264

紫书第八章第九章刷的例题习题合集

这些是我在协会自己写的紫书例题习题的,认为有必要发的题解,我会更加偏重于思路的理解和细节的把握,所以我不会缺少必要的注释。 随着章数的后推,题目难度也越来越难,所以有些我只能在刘汝佳大神的原码基础上理解并重写——不理解我也没有心情去“默写”一遍;但是在一些细节处理上,我会按照自己的方式去写,这样对小白更加友好一些,毕竟自己也是小白嘛。当然一般来说我会在最后附上刘汝佳大神的原码。 接下来会去刷紫...

qq_40822492的博客 290

JXUFE_上海邀请赛选拔赛

总的说一下这次的情况,这次的状态不太好,期间各种小错误卡好久,freopen()不能用,也是醉了,A题题目描述有问题,就不说了,B题少考虑一种情况,G题把Yes输成YES,I题思路一直有啊,但当时一直混混沌沌的,代码写不出来,J题少写了个break,这么多低级错误,害我卡了好久,还好最后一小时的时候感觉渐渐回来了,一个个的BUG调出来了 比赛的时候卡水题真的是巨影响心情的 链接:http://

lj94093的专栏 790

Android编程经典案例解析 第7章: 图片定时滑动播放

书名:Android编程经典案例解析 作者:高成珍,钟元生 索引:ISBN967--302-28293-5 出版社:清华大学 出版时间:2015年1月 这一章实现多张图片的自动滑动展示,即每隔8秒向右移动一张图片 按书中代码输入,运行后发现程序自动退出,因为: 1. activity_main.xml中 &lt;iet.jxufe.cn.android....

tobuildapp的博客 560

HTTP/2 协议详解

HTTP/2 协议详解 作者保留所有权利。All rights reserved. 关于作者 目录 HTTP/1.x 简介 要想深刻的了解 HTTP/2 ,那么我们必须对 HTTP/1.x 本身以及它的缺点有一定程度的熟悉,而这一节,我们对 HTTP/1.x 的请求 形式以及其缺点进行一个简单的回顾。首先, HTTP/1.x 的一个非常明显的特征是...

神棍之路 3078

android 下拉刷新资源,android 下拉刷新

一个简单的仿网易新闻下拉刷新资源下载此资源下载价格为3D币,请先登录资源文件列表DropDownRefresh/.classpath,475DropDownRefresh/.project,851DropDownRefresh/.settings/org.eclipse.jdt.core.prefs,177DropDownRefresh/AndroidManifest.xml,91...

weixin_36227100的博客 113

hibernate4整合spring3出现java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;...

解决办法 原先:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 改成:<bean id="sessionFactory" class="org.springframework.orm.hibernate4...

weixin_30414155的博客 118
上一篇: 2018 湘潭邀请赛 K.2018
下一篇: JXUFE紫书第四章习题 C 4-3
JXUFE_ACMer
博客等级 码龄9年 20粉丝 52原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值