AtCoder Beginner Contest 160 D Line++ 两种走法

AtCoder Beginner Contest 240 C 阅读详情

AtCoder Beginner Contest 160   比赛人数9747  快,比赛开始后3分钟看到所有题

AtCoder Beginner Contest 160 D  Line++  两种走法

总目录详见https://blog.csdn.net/mrcrack/article/details/104454762

在线测评地址https://atcoder.jp/contests/abc160/tasks/abc160_d

 

两种走法,一种按不加X,Y的路径走,另一种按通过X,Y的路径走,两种路径取最小值。

AC代码如下

#include <cstdio>
#include <algorithm>
using namespace std;
int ans[2010];
int main(){
	int N,X,Y,i,j,a,b,d;
	scanf("%d%d%d",&N,&X,&Y);
	for(i=1;i<=N;i++)
		for(j=i+1;j<=N;j++){
			a=j-i;//一种按不加X,Y的路径走
			b=(X>i?X-i:i-X)+(Y>j?Y-j:j-Y)+1;//另一种按通过X,Y的路径走,1是指X到Y路径的长度
			d=min(a,b);//两种路径取最小值
			ans[d]++;
		}
	for(i=1;i<N;i++)printf("%d\n",ans[i]);
	return 0;
}
 

比赛还是出了些状况

网站又慢,屡屡刷新,啥都没看见,让人崩溃。

VMvare 桥接模式无法联网、没有未桥接的主机网络适配器,无法将网络更改为桥接状态。 很多程序员,整天沉浸在业务代码的 CRUD 中,业务中没有大量数据做并发,缺少实战经验,对并发仅仅停留在了解,做不到精通,所以总是与大厂擦肩而过。我把私藏的这套并发体系的笔记和思维脑图分享出来,理论知识与项目实战的结合,我觉得只要你肯花时间用心学完这些,一定可以快速掌握并发编程。《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!战项目源码讲义》点击传送门即可获取!** 阅读详情

相关推荐

手把手教你用微信小程序实现智能硬件音视频通话(含Linux/RTOS适配)

本文详细介绍了如何利用微信小程序硬件框架(WMPF)和音视频SDK,在智能硬件(包括Linux与RTOS设备)上实现音视频通话功能。文章从架构设计、设备端SDK集成、小程序VOIP插件开发到跨平台调试与性能优化,提供了全链路实战指南,帮助开发者打通微信小程序与嵌入式设备间的实时音视频通信。

ooo22的博客 345

AtCoder Beginner Contest 160 题解(F待填坑)

A Coffee 题意:给你一个字符串,判断第3、4个字符是否相同,第5、6个字符是否相同。 模拟水题。直接判断就好。 #include<bits/stdc++.h> using namespace std; signed main() { string a; cin>>a; if(a[2]==a[3]&&a[4]==a[5])cou...

Bazoka13的博客 1491

【PT+Arduino+OneNET基础教程1】PacketTracer中MCU芯片编程教程(零基础入门)

PacketTracer软件内MCU芯片编程入门 零基础

ChloeMax_的博客 9470

AtCoder Beginner Contest 160

AtCoder Beginner Contest 160

青少年趣味编程 901

【实战指南】WinPE环境下360系统急救箱的病毒查杀全流程解析

本文详细解析了在WinPE环境下使用360系统急救箱进行病毒查杀的全流程。从制作WinPE启动盘到进入PE环境,再到360急救箱的深度使用和系统修复,提供了实用技巧和常见问题解决方案,帮助用户高效清除顽固病毒。

weixin_28568819的博客 542

Qt开发实战:QWebEngineView缓存路径详解与自定义配置(Windows/Linux)

本文详细解析了Qt框架中QWebEngineView组件的缓存机制,提供了Windows和Linux系统下的默认缓存路径及自定义配置方案。通过实战代码示例,展示了如何实现跨平台缓存路径管理、权限设置以及企业级应用中的多用户隔离策略,帮助开发者有效管理Web内容缓存,提升应用性能和数据安全性。

weixin_42519826的博客 407

AtCoder Beginner Contest 160题解

爆炸记

curry的博客 505

Fortran环境配置:VS2022+Intel oneAPI安装全流程指南

Fortran环境配置:VS2022+Intel oneAPI安装全流程指南

shuyisuisuinian的博客 2万+

AtCoder Beginner Contest 160(D、E、F

D - Line++ 题意: 给n,x,y 表示存在一个n个顶点的无向图图,对于每一对(i,i+1)都存在边,那么整个图就是一条链 现在顶点x和顶点y之间添加了一条边, 所有边的长度都是1 现在问: 有多少点对(a,b),满足a到b的最短距离为1,输出点对数量, 有多少点对(a,b),满足a到b的最短距离为2,输出点对数量, 有多少点对(a,b),满足a到b的最短距离为3,输出点对数量, … 有...

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 359

服务器取证——服务器基础知识

服务器基础知识

记录并分享学习安全的知识点.. 2490

MATLAB应用实战系列(七十七)-基于长时间序列栅格数据的MK检验

1 MK检验介绍 MK检验是曼-肯德尔法,又称Mann—Kenddall 检验法,是一种气候诊断与预测技术,应用Mann-Kendall检验法可以判断气候序列中是否存在气候突变,如果存在,可确定出突变发生的时间。Mann-Kendall检验法也经常用于气候变化影响下的降水、干旱频次趋势检测。目前常用于长时间序列的栅格数据的显著性检验,在植被覆盖度,NDVI,NPP等方面尤为常见。 该检验功能强大,不需要样本遵从一定的分布,部分数据缺失不会对结果造成影响,不受少数异常值的干扰,适用性强。不但可以检验时

wenyusuran的专栏 6296

AtCoder - ABC 160 - DE(贪心)

有一个有 N 个点的无向图G,相邻两点间有一条边,在顶点 X, Y 之间加一条边,总共有 N 条边。对于k从 1 到 N,求出对于每个 k,图G中满足两点最短路径为 k 的整数对数。

m0_64172681的博客 412

YOLO模型在STM32微控制器上的部署:1.98M参数如何塞进嵌入式设备?

<think>我们根据内容生成不超过150字的摘要。内容主要是关于YOLO模型在STM32微控制器上的部署,包括STM32N6 NPU、模型量化、工具链、开源方案和架构设计。摘要需要简洁概括主要点。 字数限制:≤150字。需要包含关键信息:STM32N6运行YOLO,困难,方案(NPU、INT8量化、工具链),性能(34 FPS 9.4mJ)。结尾可能提到开源和生态。 写中文摘要。注意不超过150字。</think>本文探讨YOLO模型在STM32微控制器上的部署。集成NPU的STM32N6搭配轻量化YOL

2601_95807009的博客 261

AtCoder Beginner Contest 160 D.Line++

AtCoder Beginner Contest 160 D.Line++ 题目链接 Problem Statement We have an undirected graph G with N vertices numbered 1 to N and N edges as follows: For each i=1,2,…,N−1, there is an edge between Vertex...

旺崽的博客 2663

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

AtCoder Beginner Contest 160 D - Line++

整理的算法模板:ACM算法模板总结(分类详细版) D - Line++ Time Limit: 2 sec / Memory Limit: 1024 MB Score :400400points Problem Statement We have an undirected graphGGwithNNvertices numbered11toNNandN...

wait 395

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

AtCoder Beginner Contest 421 题解

本文包含两个编程题目解答:1) A Misdelivery 判断指定位置的字符串是否匹配;2) B Fibonacci Reversed 计算斐波那契数列并反转输出。两个程序都使用了标准的C++输入输出和数据结构处理,其中第二题还涉及字符串反转操作。

nike0good |Oier&ACMer | 熟能生巧 1037

Devexpress16.2.6破解工具

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

AtCoder Beginner Contest 312

AtCoder Beginner Contest 312

青少年趣味编程 657

AtCoder Beginner Contest 263

AtCoder Beginner Contest 263

青少年趣味编程 666

AtCoder Beginner Contest 443 A~D

(因为只能向上移动),同时又要保证与前一列的棋子行数相差不超过一,也就是不能超过。从工作开始到结束,高桥君总共浏览 “chokutter” 的秒数是多少?表示每一次 “chokutter" 被关掉后又被打开的时间点,那么。在节分祭上,人们会吃与自己年龄相同数量的豆子。的值是已经确定的,因此我们可以把题意转换成:在满足条件的情况下,求。高桥君是长生不老的,因此最终他一定能从今年起累计吃掉至少。的值既满足题目的约束条件,又是第。的网格,每一列中放置了一个棋子。列的棋子初始位于从顶部数起的第。

H_Caibird的博客 693

AtCoder Beginner Contest 424 题解

nike0good |Oier&ACMer | 熟能生巧 34

AtCoder Beginner Contest 443(ABCDEF)

ABC443

2402_89326161的博客 591

AtCoder Beginner Contest 244

A - Last Letter 题意 给定一个字符串输出最后一个字符 思路: 语法题,见代码 时间复杂度 : O(n) AC代码: #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; const int N = 2e5+10,M = N * 2,INF = 0x3f3f3f3f,P = 9901; int main() { std::io...

qq_62213124的博客 2437

AtCoder Beginner Contest 430 题解

题目要求计算满足特定条件的排列数。给定长度为N的整数序列A和正整数D,要求通过重新排列A得到序列B,使得对于所有1≤i≤N-1,满足B_{i+1}≥B_i-D。采用插入法解题思路,每次按升序插入元素,确保新插入的数与后一个数满足差值条件。最终结果需对998244353取模。实现时通过预处理阶乘和逆元来优化组合数计算。

nike0good |Oier&ACMer | 熟能生巧 995

AtCoder Beginner Contest 352 A~F

有N个车站,列车的运行有两种方向,即1→n和n→1两种。问,从x点到y点,仅乘坐一次列车,是否会经过站点z。

Code_Shark的博客 652

AtCoder Beginner Contest 087 D People on a Line(DFS)

题意 给出n个点,m组关系L,R,D,L在R的左边距离D,判断是否存在n个人的位置满足m组关系 分析 Consider the following directed graph G: There are N vertices numbered 1,2,...,N. For each i, there are an edge from vertex Li to vertex Ri wit...

anquan1533的博客 207

OMRON Corporation Programming Contest 2025 #2 (AtCoder Beginner Contest 432) 题解

摘要:给定三个1到9之间的数字A、B、C,通过排列组合生成所有可能的三位数,并找出其中的最大值。代码实现中,将数字排序后按降序输出即可得到最大三位数。例如,输入3、1、2,排序后得到3、2、1,输出321即为最大值。

nike0good |Oier&ACMer | 熟能生巧 311
上一篇: AtCoder Beginner Contest 160 E Red and Green Apples 自大到小排序+每读入一个数据,记录各种颜色苹果数量变化
下一篇: codeforces拾遗
mrcrack
博客等级 码龄15年 1072粉丝 1063原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值