蓝桥杯(3.10)
1219. 移动距离
import java.util.Scanner;
public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);int w = sc.nextInt();int m = sc.nextInt();int n = sc.nextInt();m--;n--;//由从1开始变为从0开始//求行号int x1 = m/w, x2 = n/w;//求列号int y1 = m%w, y2 = n%w;if(x1%2 != 0) y1 = w-y1-1;if(x2%2 != 0) y2 = w-y2-1;System.out.println(Math.abs(x1-x2)+Math.abs(y1-y2));//曼哈顿距离}
}
1229. 日期问题
import java.util.Scanner;public class Main{static int[] days = new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};public static void main(String[] args) {Scanner sc = new Scanner(System.in);String[] s = sc.nextLine().split("/");for(int i=19600101;i<=20591231;i++) {int year = i/10000;int year2 = year%100;int month = i/100 %100;int day = i%100;int s1 = Integer.parseInt(s[0]);int s2 = Integer.parseInt(s[1]);int s3 = Integer.parseInt(s[2]);if((year%100!=0 && year%4 == 0)||(year%400 == 0))days[2] = 29;elsedays[2] = 28;//注意boolean f1 = false;boolean f2 = false;boolean f3 = false;//日月相等或者月日相等if(s1 == s2 && s2 == s3){//12/12/12f1 = true;}else if(s1 == s2){12/12/06f1 = true;f2 = true;}else if(s1 == s3){//12/06/12f1 = true;f3 = true;}else{//06/07/12f1 = true;f2 = true;f3 = true;}//没有s2 == s3 这种的样例//年月日if(f1){if(year2 == s1&&month == s2&&day == s3) {if((month>=1 && month<=12) && (day>=1 && day<=days[month]))System.out.printf("%d-%02d-%02d\n",year,month,day);}}//日月年if(f2){if(day == s1&&month == s2&&year2 == s3) {if((month>=1 && month<=12) && (day>=1 && day<=days[month]))System.out.printf("%d-%02d-%02d\n",year,month,day);} }//月日年if(f3){if(month == s1&&day == s2&&year2 == s3) {if((month>=1 && month<=12) && (day>=1 && day<=days[month]))System.out.printf("%d-%02d-%02d\n",year,month,day);} }}}
}
if合并
import java.util.Scanner;public class Main{static int[] days = new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};public static void main(String[] args) {Scanner sc = new Scanner(System.in);String[] s = sc.nextLine().split("/");for(int i=19600101;i<=20591231;i++) {int year = i/10000;int year2 = year%100;int month = i/100 %100;int day = i%100;int s1 = Integer.parseInt(s[0]);int s2 = Integer.parseInt(s[1]);int s3 = Integer.parseInt(s[2]);if((year%100!=0 && year%4 == 0)||(year%400 == 0))days[2] = 29;elsedays[2] = 28;//注意if(year2 == s1&&month == s2&&day == s3||day == s1&&month == s2&&year2 == s3||month == s1&&day == s2&&year2 == s3) {if((month>=1 && month<=12) && (day>=1 && day<=days[month]))System.out.printf("%d-%02d-%02d\n",year,month,day);}}}
}
1101. 献给阿尔吉侬的花束
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;public class Main{static int r;static int c;static final int N = 210;static char[][] g = new char[N][N];static int[][] dis = new int[N][N];static int[] dx = {1,-1,0,0};static int[] dy = {0,0,1,-1};public static int bfs(PII start,PII end) {Deque<PII> dq = new LinkedList<>();for(int i=0;i<r;i++)for(int j=0;j<c;j++)dis[i][j] = -1;dis[start.x][start.y] = 0;dq.addLast(start);while(!dq.isEmpty()) {PII t = dq.pollFirst();//取出队头元素并且删除for(int i=0;i<4;i++) {int x = t.x+dx[i],y = t.y+dy[i];if(x<0 || x>(r-1) || y<0 || y>(c-1)) continue;if(g[x][y] == '#') continue;if(dis[x][y] != -1) continue;dis[x][y] = dis[t.x][t.y] + 1;if(end.x == x && end.y == y)return dis[x][y];dq.addLast(new PII(x,y));}}return -1;}public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();sc.nextLine();while(t-- != 0) {r = sc.nextInt();c = sc.nextInt();sc.nextLine();for(int i=0;i<r;i++)g[i] = sc.nextLine().toCharArray();PII start = null,end = null;for(int i=0;i<r;i++) {for(int j=0;j<c;j++) {if(g[i][j] == 'S')start = new PII(i,j);if(g[i][j] == 'E')end = new PII(i,j);}}int distance = bfs(start,end);if(distance == -1) System.out.println("oop!");else System.out.println(distance);}}
}class PII{int x;int y;public PII(int x,int y) {this.x = x;this.y = y;}
}
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;public class Main{static int r;static int c;static final int N = 210;static char[][] g = new char[N][N];static int[][] dis = new int[N][N];static int[] dx = {1,-1,0,0};static int[] dy = {0,0,1,-1};public static int bfs(int[] start,int[] end) {Deque<int[]> dq = new LinkedList<>();for(int i=0;i<r;i++)for(int j=0;j<c;j++)dis[i][j] = -1;dis[start[0]][start[1]] = 0;dq.addLast(start);while(!dq.isEmpty()) {int[] t = dq.pollFirst();//取出队头元素并且删除for(int i=0;i<4;i++) {int x = t[0]+dx[i],y = t[1]+dy[i];if(x<0 || x>(r-1) || y<0 || y>(c-1)) continue;if(g[x][y] == '#') continue;if(dis[x][y] != -1) continue;dis[x][y] = dis[t[0]][t[1]] + 1;if(end[0] == x && end[1] == y)return dis[x][y];dq.addLast(new int[]{x,y});}}return -1;}public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();sc.nextLine();//while(t-- != 0) {r = sc.nextInt();c = sc.nextInt();sc.nextLine();//for(int i=0;i<r;i++)g[i] = sc.nextLine().toCharArray();int[] start = new int[2];int[] end = new int[2];for(int i=0;i<r;i++) {for(int j=0;j<c;j++) {if(g[i][j] == 'S')start = new int[]{i,j};if(g[i][j] == 'E')end = new int[]{i,j};}}int distance = bfs(start,end);if(distance == -1) System.out.println("oop!");else System.out.println(distance);}}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Deque;
import java.util.LinkedList;public class Main{static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));static final int N = 210;static int r;static int c;static int[][] dis = new int[N][N];static char[][] ch = new char[N][N];public static int bfs(int[] start,int[] end) {Deque<int[]> dq = new LinkedList<>();for(int i=0;i<r;i++)for(int j=0;j<c;j++)dis[i][j] = -1;dis[start[0]][start[1]] = 0;dq.addLast(start);int[] dx = {1,-1,0,0};int[] dy = {0,0,1,-1};while(!dq.isEmpty()) {int[] t = dq.pollFirst();for(int i=0;i<4;i++) {int x = t[0] + dx[i];int y = t[1] + dy[i];if(x<0 || x>r-1 || y<0 || y > c-1)continue;if(ch[x][y] == '#')continue;if(dis[x][y] != -1)continue;dis[x][y] = dis[t[0]][t[1]]+1;if(end[0] == x && end[1] == y)return dis[x][y];dq.addLast(new int[]{x,y});}}return -1;}public static void main(String[] args) throws IOException{int n = Integer.parseInt(br.readLine());//测试数据组数while(n-- != 0) {String[] s = br.readLine().split(" ");r = Integer.parseInt(s[0]);c = Integer.parseInt(s[1]);for(int i=0;i<r;i++)ch[i] = br.readLine().toCharArray();int[] start = new int[2];int[] end = new int[2];for(int i=0;i<r;i++)for(int j=0;j<c;j++) {if(ch[i][j] == 'S')start = new int[] {i,j};if(ch[i][j] == 'E')end = new int[] {i,j}; }int distance = bfs(start,end);if(distance == -1) System.out.println("oop!");elseSystem.out.println(distance);}}
}
1224. 交换瓶子
import java.util.*;
public class Main{static final int N = 10010;static int[] a = new int[N];static boolean[] b = new boolean[N];public static void main(String[] args){Scanner sc = new Scanner(System.in);int n = sc.nextInt();for(int i=1;i<=n;i++)a[i] = sc.nextInt();int sum = 0;for(int i=1;i<=n;i++){if(!b[i]){sum++;for(int j=i;!b[j];j = a[j])b[j] = true;}}System.out.println(n - sum);}
}
1240. 完全二叉树的权值
import java.util.Scanner;
public class Main{static final int N = 100010;public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] res = new int[N];for(int i=1;i<=n;i++)res[i] = sc.nextInt();long max = Long.MIN_VALUE;int dp = 0;for(int i=1,d=1;i<=n;d++,i*=2) {//i表示每一层的第一个位置//d表示层数long sum = 0;//for(int j=i;j<(i+(1<<d-1)) && j<=n;j++)//完全二叉树最后一层可能不满所以要j<=nsum+=res[j];if(sum>max) {max = sum;dp = d;}}System.out.println(dp);}
}
1096. 地牢大师
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;public class Main{static int l;static int r;static int c;static final int N = 110;static char[][][] ch = new char[N][N][N];static int[][][] dis = new int[N][N][N];static int[] dx = {1,-1,0,0,0,0};static int[] dy = {0,0,1,-1,0,0};static int[] dz = {0,0,0,0,1,-1};public static int bfs(int[] start,int[] end) {Deque<int[]> dq = new LinkedList<>();for(int i=0;i<l;i++)for(int j=0;j<r;j++)for(int k=0;k<c;k++) {dis[i][j][k] = -1;}dis[start[0]][start[1]][start[2]] = 0;dq.addLast(start);while(!dq.isEmpty()) {int[] t = dq.pollFirst();for(int i=0;i<6;i++) {int x = t[0]+dx[i];int y = t[1]+dy[i];int z = t[2]+dz[i];if(x<0 || x>l-1 || y<0 || y>r-1 || z<0 || z>c-1)continue;if(ch[x][y][z] == '#')continue;if(dis[x][y][z] != -1)continue;dis[x][y][z] = dis[t[0]][t[1]][t[2]] + 1;if(end[0] == x && end[1] == y && end[2] == z)return dis[x][y][z];dq.addLast(new int[] {x,y,z});}}return -1;}public static void main(String[] args) {Scanner sc = new Scanner(System.in);while(sc.hasNext()) {l = sc.nextInt();r = sc.nextInt();c = sc.nextInt();if(l == 0 && r == 0 && c == 0)return ;int[] start = new int[3];int[] end = new int[3];for(int i = 0;i < l;i ++){for(int j = 0;j < r;j ++){char[] charArray = sc.next().toCharArray();for(int k = 0;k < c;k ++){ch[i][j][k] = charArray[k];if(ch[i][j][k] == 'S') start = new int[] {i,j,k};if(ch[i][j][k] == 'E') end = new int[] {i,j,k};}}}int distance = bfs(start,end);if(distance == -1)System.out.println("Trapped!");elseSystem.out.printf("Escaped in %d minute(s).\n",distance);}}
}
相关文章:
蓝桥杯(3.10)
1219. 移动距离 import java.util.Scanner; public class Main{public static void main(String[] args) {Scanner sc new Scanner(System.in);int w sc.nextInt();int m sc.nextInt();int n sc.nextInt();m--;n--;//由从1开始变为从0开始//求行号int x1 m/w, x2 n/w;//…...
Hololens 2应用开发系列(3)——MRTK基础知识及配置文件配置(中)
Hololens 2应用开发系列(3)——MRTK基础知识及配置文件配置(中) 一、前言二、输入系统2.1 MRTK输入系统介绍2.2 输入数据提供者(Input Data Providers)2.3 输入动作(Input Actions)2…...
吴恩达深度学习笔记:深度学习引言1.1-1.5
目录 第一门课:神经网络和深度学习 (Neural Networks and Deep Learning)第一周:深度学习引言(Introduction to Deep Learning)1.1 欢迎(Welcome)1.2 什么是神经网络?(What is a Neural Network)1.3 神经网络的监督学习(Supervised Learning …...
【Hadoop大数据技术】——Hadoop概述与搭建环境(学习笔记)
📖 前言:随着大数据时代的到来,大数据已经在金融、交通、物流等各个行业领域得到广泛应用。而Hadoop就是一个用于处理海量数据的框架,它既可以为海量数据提供可靠的存储;也可以为海量数据提供高效的处理。 目录 &#…...
蓝桥杯2023年第十四届省赛真题-工作时长
文件数据 把数据复制到excel中 数据按照增序排序 选中列数据,设置单元格格式,选择下述格式。注意,因为求和之后总小时数可能会超过24小时,所以不要选择最前面是hh的 设置B2 A2 - A1, B4 A4 - A3;然后选中已经算出…...
nginx禁止国外ip访问
1.安装geoip2扩展依赖 yum install libmaxminddb-devel -y 2.下载ngx_http_geoip2_module模块 https://github.com/leev/ngx_http_geoip2_module.git 3.编译安装 ./configure --add-module/datasdb/ngx_http_geoip2_module-3.4 4.下载最新数据库文件 模块安装成功后,还要…...
《腾讯音乐》24校招Java后端一面面经
1.手写LRU 2.项目拷打 3.Https客户端校验证书的细节? 4.对称加密和非对称加密的区别?你分别了解哪些算法? 5.在信息传输过程中,Https用的是对称加密还是非对称加密? 6.怎么防止下载的文件被劫持和篡改? 7.H…...
JavaScript:ES至今发展史简说
ECMAScript(简称ES)是JavaScript的标准,它的发展史经历了多个版本的迭代,以下是主要里程碑: ES1 (1997年6月):首个正式发布的ECMAScript标准,基于当时的JavaScript(由Netscape公司开…...
Linux:进程
进程 知识铺垫冯诺依曼体系结构操作系统(OS) 进程概念进程的查看ps 命令获取进程 pid文件内查看进程终止进程的方式kill命令快捷键 进程的创建 forkfork 返回值问题 进程状态运行状态 :R休眠状态:S (可中断)…...
【Vue3】defineExpose 实践
【Vue3】defineExpose 实践 defineExpose 是 Vue 3 的 <script setup> 语法糖中提供的一个函数,用于显式地暴露组件的属性、方法或其他响应式状态给其父组件或外部使用。这是在使用 <script setup> 语法时,控制组件公开哪些内部状态和方法的…...
centos7.9安装nacos
centos7.9安装nacos2.3.1 在centos x86_64环境安装nacos2.31环境准备 jdk1.8 、 mysql、 nacos 在window11环境安装nacos2.31 在centos x86_64环境安装nacos2.31 环境准备 jdk1.8 、 mysql、 nacos Nacos 依赖 Java 环境来运行。我们通过下载编译后压缩包方式安装。 重点踩坑…...
ARM/Linux嵌入式面经(四):浙江大华
大华一面 嵌入式 主要是问的项目相关 标准的十五分钟 电话面 这个面试官主要问项目,我同门面的全问八股,可能面试官不一样吧 文章目录 UART串口通信的波特率,常用波特率有哪些串口通信校验方式是什么,有什么区别方便简单的奇偶校验偶校验(even parity)累加和校验CRC循环冗…...
ubuntu 18.04安装教程(详细有效)
文章目录 一、下载ubuntu 18.04镜像二、安装ubuntu1. 点击下载好的Vmware Workstation,点击新建虚拟机,选择 “自定义(高级)”,之后下一步。2. 默认配置,不需要更改,点击下一步。3. 选择 “安装程序光盘映像文件(iso)(…...
第二十一天-NumPy
目录 什么是NumPy NumPy使用 1.数组的创建 2.类型转换 3.赠删改查 4.数组运算 5.矩阵运算 什么是NumPy 1.NumPy操作的是多维数组,什么是纬度? NumPy使用 1. 安装 pip install numpy import numpy as np 2.官网: 中文官网:…...
Vue:自动按需导入element-plus图标
自动导入使用 unplugin-icons 和 unplugin-auto-import 从 iconify 中自动导入任何图标集。 完整vite.config.js参考模板 https://download.csdn.net/download/ruancexiaoming/88928539 动态导入图标参考 https://blog.csdn.net/ruancexiaoming/article/details/136568219 导入…...
魔法之线:探索string类的神秘世界
🎉个人名片: 🐼作者简介:一名乐于分享在学习道路上收获的大二在校生 🙈个人主页🎉:GOTXX 🐼个人WeChat:ILXOXVJE 🐼本文由GOTXX原创,首发CSDN&…...
使用gnvm下载nodejs和npm
目录 前言 一、下载gnvm 二、利用gnvm下载nodejs 三、下载对应版本的npm 四、gnvm常用的命令 总结 前言 由于之前下载的版本过低,需要升级版本。但在使用gnvm升级node版本时遇到了一系列的问题,索性就把nodejs全部删除,重新用gnvm在下…...
C语言——简易版扫雷
目录 前言 编辑 游戏规则 游戏结构的分析 游戏的设计 使用多文件的好处有以下几点: 游戏代码实现 框架(test.c) game函数(test.c) InitBoard初始化(game.c) Print打印棋盘(g…...
L3自动驾驶的“双保险”:冗余EPS关键技术解析
摘要: 本文主要介绍冗余EPS的发展路径和关键技术。 引言 在乘用车领域,电动助力转向系统(Electric Power Steering,EPS)相比传统的液压助力转向系统(Hydraulic Power Steering,HPS)具有结构简单、响应迅速、能耗低等优点,因此应用很广。随着智能驾驶的发展,作为底层…...
java.net.UnknownHostException
目录 报错信息 报错分析 UnknownHostException 分析 尝试解决 域名 报错可能 网络请求: 数据库连接: Socket通信: 总结: 报错信息 java.net.UnknownHostException Caused by: java.net.UnknownHostException:at java.…...
打造沉浸式智能AI问答助手:Vue + UniApp 全端实战(支持 Markdown/公式/多模态交互)唇
OCP原则 ocp指开闭原则,对扩展开放,对修改关闭。是七大原则中最基本的一个原则。 依赖倒置原则(DIP) 什么是依赖倒置原则 核心是面向接口编程、面向抽象编程, 不是面向具体编程。 依赖倒置原则的目的 降低耦合度&#…...
在超大数据集下 DuckDB 与 MySQL 查询速度对比排
一、什么是urllib3? urllib3 是一个用于处理 HTTP 请求和连接池的强大、用户友好的 Python 库。 它可以帮助你: 发送各种 HTTP 请求(GET, POST, PUT, DELETE等)。 管理连接池,提高网络请求效率。 处理重试和重定向。 支…...
四轮独立驱动汽车轨迹跟踪与横向稳定性控制:MPC控制器与二次规划方法结合应用,基于MATLAB...
四轮独立驱动汽车自动轨迹跟踪横向稳定性控制 CarSim与Simulink联合 控制目标为对给定轨迹进行跟踪(不带轨迹规划)同时进行横向稳定性控制 上层控制器为MPC控制器,输出为附加横摆力矩和方向盘转角,采用了二自由度车辆模型 MPC控制器采用代码编写,原理一目…...
把 Flask 搬进 ESP,高中生自研嵌入式 Web 框架 MicroFlask !唤
如果有多个供应商,你也可以使用 [[CC-Switch]] 来可视化管理这些API key,以及claude code 的skills。 # 多平台安装指令 curl -fsSL https://claude.ai/install.sh | bash ## Claude Code 配置 GLM Coding Plan curl -O "https://cdn.bigmodel.cn/i…...
第8章 流程控制-8.3 循环结构
循环结构就是让程序不断地重复执行同一段代码。Python中的循环结构有3种,分别是while循环、for循环和循环嵌套。8.3.1 while循环while循环可以通过while语句和while…else语句实现。1.while语句while语句首先会判断其条件表达式是否成立,如果条件表达式成…...
打字不如说话,说话不如截图——AI 代码助手的多模态输入实践伺
整体排查思路 我们的目标是验证以下三个环节是否正常: 登录成功时:服务器是否正确生成了Session并返回了包含正确 JSESSIONID的Cookie给浏览器。 浏览器端:浏览器是否成功接收并存储了该Cookie。 后续请求:浏览器在执行查询等操作…...
使用Spring AI Alibaba构建智能体Agent倥
背景 在软件开发的漫长旅途中,"构建"这个词往往让人又爱又恨。爱的是,一键点击,代码变成产品,那是程序员最迷人的时刻;恨的是,维护那一堆乱糟糟的构建脚本,简直是噩梦。 在很多项目中…...
FLUX.1-schnell终极指南:如何在4步内生成专业级AI图像
FLUX.1-schnell终极指南:如何在4步内生成专业级AI图像 【免费下载链接】FLUX.1-schnell 项目地址: https://ai.gitcode.com/hf_mirrors/black-forest-labs/FLUX.1-schnell 想象一下,你只需要输入简单的文字描述,就能在短短几秒钟内获…...
Polyglot配置完全手册:OpenAI Key与Azure TTS服务设置详解
Polyglot配置完全手册:OpenAI Key与Azure TTS服务设置详解 【免费下载链接】polyglot 🤖️ Cross-platform AI language practice app (跨平台AI语言练习应用) 项目地址: https://gitcode.com/gh_mirrors/po/polyglot Poly…...
世界第一个开源可商用 .NET Office 转 PDF 工具/库 - MiniPdf盐
1. 智能软件工程的范式转移:从库集成到原生框架演进 在生成式人工智能(Generative AI)从单纯的文本生成向具备自主规划与执行能力的“代理化(Agentic)”系统跨越的过程中,.NET 生态系统正在经历一场自该平台…...
