自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(118)
  • 资源 (5)
  • 收藏
  • 关注

原创 1120 Friend Numbers (20 point(s))

思路:计算字符串的digit和,放入集合 set 。1120 Friend Numbers (20 point(s))Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6

2021-04-13 21:13:11 138

原创 1142 Maximal Clique (25 point(s))

思路:1. 利用 map 统计查询里的结点出现的次数,当查询结点出现在图中时加1,当查询结点出现在邻接结点时加1;2. 统计 map 中出现次数为 K(查询结点数) 的结点数量 KGraph,附加条件(同时处于查询结点中)KQuery,当KGraph ==KQuery 时,为最大 clique,否则不是 Max clique,如果KQuery < K 则 not a clique。1142 Maximal Clique (25 point(s))Acliqueis a s...

2021-04-13 21:02:45 141

原创 1143 Lowest Common Ancestor (30 point(s))

思路:1. 对 BST 的先序排列,进行递增排序,得到中序排列,利用先序+中序,可得整棵 BST2. 如果在中序排列中,根结点处于X和Y之间,那么根节点就是 LCA,否则在左子树,或者右子树1143 Lowest Common Ancestor (30 point(s))The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as des

2021-04-13 19:23:40 142

原创 1140 Look-and-say Sequence (20 point(s))

思路:字符串处理,识别连续的digit个数。1140 Look-and-say Sequence (20 point(s))Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...whereDis in [0, 9] except 1. The (n+1)st number is a kind of description o..

2021-04-06 10:50:25 95

原创 1141 PAT Ranking of Institutions (25 point(s))

思路:c++/STL,利用map保存输入,然后计算ScoreX,然后输出到vector,最后sort排序,输出排序结果。1141 PAT Ranking of Institutions (25 point(s))After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate th

2021-04-06 09:04:10 51

原创 1102 Invert a Binary Tree (25 point(s))

思路:每个节点保存左孩子,右孩子,和双亲节点,利用双亲结点找到根节点root,然后就可以从根结点层次遍历,和中序遍历,遍历顺序从右到左。1102 Invert a Binary Tree (25 point(s))The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary

2021-04-05 11:22:03 54

原创 HJ 82 将真分数分解为埃及分数

思路:1. 暴力破解算法,从 [2, INT_MAX] 选择分母,组成埃及分数 1/Temp , 与原分数相减,得到新的真分数,继续选择 Temp,知道相减后的结果是0;挑选 Temp 的时间复杂度为 O(n);2. 贪心算法,假设原真分数为 0 < a / b < 1,令商 q = b / a,余数 r = b % a,可知真分数a / b > 1/ (q+1) ,可以选择 q+1 作为暴力破解选出的分母 Temp,挑选 Temp 的时间复杂度为 O(1); 然后相减,.

2021-03-23 16:37:40 513 1

原创 HJ 44 Sudoku-Java

思路:递归。采用深度遍历,根据纵横,3X3,跳出候选的数字,然后根据这个数字,继续遍历,如果遇到不满足调剂的返回,使用下一个候选数字,最后能成功到达末行最后一个数字,就是成功解决。题目描述问题描述:数独(Sudoku)是一款大众喜爱的数字逻辑游戏。玩家需要根据9X9盘面上的已知数字,推算出所有剩余空格的数字,并且满足每一行、每一列、每一个粗线宫内的数字均含1-9,并且不重复。输入:包含已知数字的9X9盘面数组[空缺位以数字0表示]输出:完整的9X9盘面数组Example:

2021-03-21 10:58:32 182

原创 HJ 31 【中级】单词倒排

思路:从字符串最后往前遍历,将 alpha 入栈,跳过非 alpha。题目描述对字符串中的所有单词进行倒排。说明:1、构成单词的字符只有26个大写或小写英文字母;2、非构成单词的字符均视为单词间隔符;3、要求倒排后的单词间隔符以一个空格表示;如果原字符串中相邻单词间有多个间隔符时,倒排转换后也只允许出现一个空格间隔符;4、每个单词最长20个字母;Example:#include<iostream>#include<vector>#incl

2021-03-19 10:34:07 135

原创 HJ 27 查找兄弟单词

思路:利用map保存每个单词出现的次数,然后遍历,如果是兄弟单词,就统计下标,和总个数,最后输出结果。查找兄弟单词题目描述定义一个单词的“兄弟单词”为:交换该单词字母顺序,而不添加、删除、修改原有的字母就能生成的单词。兄弟单词要求和原来的单词不同。例如:ab和ba是兄弟单词。ab和ab则不是兄弟单词。现在给定你n个单词,另外再给你一个单词str,让你寻找str的兄弟单词里,字典序第k大的那个单词是什么?注意:字典中可能有重复单词。本题含有多组输入数据。输入描述:先输入单

2021-03-18 11:23:09 259

原创 HJ 20 密码验证合格程序

思路:先统计大小写,数字,其他出现的情况,接着判断长度,最后判断是否有重复子串。子串的统计,复杂度为O(N2);题目描述密码要求:1.长度超过8位2.包括大小写字母.数字.其它符号,以上四种至少三种3.不能有相同长度大于2的子串重复输入描述:一组或多组长度超过2的字符串。每组占一行输出描述:如果符合要求输出:OK,否则输出NG示例1输入021Abc9000021Abc9Abc1021ABC9000021$bc9000输出OKNG

2021-03-18 10:20:45 247

原创 HJ 18 识别有效的IP地址和掩码并进行分类统计

思路:先进行出错处理,然后分类统计。题目描述请解析IP地址和对应的掩码,进行分类识别。要求按照A/B/C/D/E类地址归类,不合法的地址和掩码单独归类。所有的IP地址划分为A,B,C,D,E五类A类地址1.0.0.0~126.255.255.255;B类地址128.0.0.0~191.255.255.255;C类地址192.0.0.0~223.255.255.255;D类地址224.0.0.0~239.255.255.255;E类地址240.0.0.0~255.255..

2021-03-18 09:22:52 615

原创 HJ 19 简单错误记录

思路:根据Create_Time来排队,最后八条输出;使用vector,队尾八条记录就是,同时使用map保存下标,快速查找到对应文件。可以将文件名+行数同时保存成一个字符串。题目描述开发一个简单错误记录功能小模块,能够记录出错的代码所在的文件名称和行号。处理:1、记录最多8条错误记录,循环记录,最后只用输出最后出现的八条错误记录。对相同的错误记录只记录一条,但是错误计数增加。最后一个斜杠后面的带后缀名的部分(保留最后16位)和行号完全匹配的记录才做算是”相同“的错误记录。2.

2021-03-18 09:14:07 184

原创 1149 Dangerous Goods Packaging (25 point(s))

思路:利用 map+set 保存不兼容列表,然后查找,如果运载的货物有不能放到一起的,就输出 No, 否则输出 Yes1149 Dangerous Goods Packaging (25 point(s))When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves i

2021-03-12 16:52:49 78

原创 1148 Werewolf - Simple Version (20 point(s))

思路:暴力破解,验证组合 {(i, j) | 1<=i<=N-1, i+1<=j<=N},是否满足给定条件:1个狼人说谎,另外一个狼人不说谎,还有1个平民说谎(at least one but not all the werewolves were lying)组合 (i,j)就是解,没有就是无解。1148 Werewolf - Simple Version (20 point(s))Werewolf(狼人杀) is a game in which the pl.

2021-03-12 15:42:45 72

原创 1147 Heaps (30 point(s))

思路:二叉堆的类型,可以根据父节点跟子节点的大小比较判断;后序遍历,可以利用递归实现。1147 Heaps (30 point(s))In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater th..

2021-03-11 22:26:00 54

原创 1146 Topological Order (25 point(s))

思路:按照给定序列,如果是拓扑序列,那么就输出序号,序号从 0 开始。1146 Topological Order (25 point(s))This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to wr

2021-03-11 17:20:48 66

原创 2021-03-11

思路:哈希表,用平方探测法解决冲突,插入时 0 <= i <= Ms-1, 查询时 0 <= i <= Ms。1145 Hashing - Average Search Time (25 point(s))The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another .

2021-03-11 16:22:51 66

原创 1144 The Missing Number (20 point(s))

思路:利用set保存大于0的正数,然后得出最小missing postive number。1144 The Missing Number (20 point(s))Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case.

2021-03-10 21:51:54 91

原创 1155 Heap Paths (30 point(s))

思路:叶子节点从右到左,入栈到根节点的路径,出栈输出。1155 Heap Paths (30 point(s))In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal..

2021-03-10 21:34:54 57

原创 1154 Vertex Coloring (25 point(s))

思路:利用广度优先搜索 BFS,匹配节点与附近节点颜色是否不一样,同时需要考虑非连通图的情况,颜色的数量可以用 set 记录。1154 Vertex Coloring (25 point(s))Aproper vertex coloringis a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A colorin..

2021-03-10 17:35:07 57

原创 1153 Decode Registration Card of PAT (25 point(s))

思路:非主流思路,先设计号数据结构,让记录在录入的时候对号入座,最后查询的时候整理或者直接输出。1153 Decode Registration Card of PAT (25 point(s))A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor b...

2021-03-10 16:11:31 78

原创 1152 Google Recruitment (20 point(s))

思路:字符串转成10进制数,再判断是否素数,如果是则输出,前导0也要输出,即输出 0023 而不是 23.1152 Google Recruitment (20 point(s))In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple,

2021-03-10 14:27:12 46

原创 1151 LCA in a Binary Tree (30 point(s))

思路:递归,给定一棵树,确认根节点是否u和v的最低公共祖先,如果不是,那么对左子树或者右子树查找。如果u和v都存在树中,那么查找LCA,如果不是,打印对应错误信息。先序遍历,如果当前树的根节点是u或者v,或者中序遍历序列中,根节点的位置在u和v之间,那么LCA就是根节点;如果不是,那么中序遍历序列中,根节点的位置大于u和v,那么在左子树查找u和v的LCA,否则在右子树查找。1151 LCA in a Binary Tree (30 point(s))The lowest common

2021-03-10 11:35:16 58 1

原创 1150 Travelling Salesman Problem (25 point(s))

思路:旅行商问题,利用邻接矩阵实现无向有权图,按照给出路径访问节点,然后再根据全部节点的访问情况 Visited,判断是环\简单环\其他,除了起始节点,其他节点是否只访问1次,0次,还是大于1次,是否首尾相同等。1150 Travelling Salesman Problem (25 point(s))The "travelling salesman problem" asks the following question: "Given a list of cities and the dis

2021-03-09 17:17:06 45

原创 1034 Head of a Gang (30 point(s))

思路:利用并查集保存帮派的关系,然后逐一访问每个帮派,满足通话时长大于 K,且人数大于等于3的话,保存通话时长最长的成员名字和帮派人数,利用map保存,最后输出map的内容。参考并查集。AC 代码用单链表实现并查集,也可以用并查集森林实现。1034 Head of a Gang (30 point(s))One way that the police finds the head of a gang is to check people's phone calls. If the..

2021-03-08 21:46:56 46

原创 1033 To Fill or Not to Fill (25 point(s))

思路:分治和贪心算法,在给定范围[begin, end]内,查找价格最低的加油站;如果没有找到,可以往前 [begin, begin-A*C]的范围内找。1034 Head of a Gang (30 point(s))One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatA...

2021-02-26 16:50:15 71

原创 1032 Sharing (25 point(s))

思路:右对齐,然后遍历比较两者地址,若相等,则输出。1032 Sharing (25 point(s))To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For exampl

2021-02-26 11:22:34 97

原创 1031 Hello World for U (20 point(s))

思路:利用公式求得 n1, n2, n3,然后输出 U1031 Hello World for U (20 point(s))Given any string ofN(≥5) characters, you are asked to form the characters into the shape ofU. For example,helloworldcan be printed as:h de ll rlowoThat is, the characters...

2021-02-26 10:16:06 73

原创 1030 Travel Plan (30 point(s))

思路:图的深度优先搜索 DFS,找到得到最短路径,且开销最小的路径,并打印。1030 Travel Plan (30 point(s))A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide t

2021-02-26 09:28:25 91

原创 1029 Median (25 point(s))

思路:计算的出中位数的位置,然后比较两个数组,得出中位数,时间复杂度为 O(n+m)1029 Median (25 point(s))Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10

2021-02-26 08:46:53 88

原创 1028 List Sorting (25 point(s))

思路:利用 map 处理不同条件,若条件相同,则利用set 处理。1028 List Sorting (25 point(s))Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first li.

2021-02-25 21:16:21 70

原创 1027 Colors in Mars (20 point(s))

思路:模13和整除13的数学题。1027 Colors in Mars (20 point(s))People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are forRed, the middle 2 digi.

2021-02-25 18:10:57 66

原创 1026 Table Tennis (30 point(s))

思路:用两个队列,vip队列和普通队列,找到完成时间最早的窗口,如果比两个队列最早的人的到达时间还早,就更新窗口完成时间为两者最小值,然后回到开头重新找完成时间最早的窗口;若选中vip队列,则重新查找窗口,优先选 vip 窗口;若选中普通队列,则使用该窗口;注意:vip玩家,优先分配vip桌子 等待时间大于等于30秒,进一分钟,小于30秒则舍去的原则; 游戏时长不能超过 120 分钟1026 Table Tennis (30 point(s))A table tennis

2021-02-25 17:45:32 60

原创 1025 PAT Ranking (25 point(s))

思路:在全局,和局部下,记录对应分数有多少人,再排名1025 PAT Ranking (25 point(s))Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the rankl

2021-02-25 14:37:44 55

原创 1024 Palindromic Number (25 point(s))

思路:先判断是否回环数,如果不是,就首尾相加,然后再判断是否回环数。1024 Palindromic Number (25 point(s))A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers ar.

2021-02-25 10:59:25 120 1

原创 1023 Have Fun with Numbers (20 point(s))

思路:从后往前访问字符串,乘以2后入栈,统计相应 digit 出现的次数;计算栈的 digit 统计出现次数,如果两者不相同,则输出 No,否则输出 Yes最后输出翻倍后的字符串。1023 Have Fun with Numbers (20 point(s))Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication

2021-02-25 10:06:02 49

原创 1022 Digital Library (30 point(s))

思路:每个查询条件建立索引,索引 id 号,利用 Map 是红黑树实现的特性,快速建立/查询索引。1022 Digital Library (30 point(s))A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is as

2021-02-24 17:23:39 57

原创 1021 Deepest Root (25 point(s))

思路:利用深度优先搜索 DFS,获得连通分量的个数,若个数大于 1 ,则输出错误消息;若连通分量分数为1,则利用广度优先搜索 BFS 获取根的对应深度,从中输出满足最大值的结点。1021 Deepest Root (25 point(s))A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you ar

2021-02-24 15:52:47 118

原创 1020 Tree Traversals (25 point(s))

1020 Tree Traversals (25 point(s))Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding binary tr

2021-02-23 23:37:00 46

XBEE Python Library

XBEE Python Library 开始 用户文档 示例 API 参考 索引

2019-01-24

DIGI XBEE3 ZIGBEE3.0 用户指南

DIGI XBEE3 ZIGBEE3.0 用户指南 帧描述 ZIGBEE3.0 OTA 过程 API 操作 AT命令 管理终端设备

2019-01-24

zigbee3.0标准介绍

1.介绍zigbee3.0 2.zigbee3.0基础设备行为 3.zigbee3.0设备和应用簇 4.zigbee和物联网

2019-01-13

ARMv6M 参考手册

Application Level Architecture,System Level Architecture,Debug Architecture

2017-12-26

GNU ARM Eclipse Windows tools source

Windows-build-tools

2017-02-23

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除