自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 资源 (2)
  • 收藏
  • 关注

原创 (图论)最短路径基础算法模板总结,考前必备!!!

背景以洛谷一道简单的模板题总结一下解决最短路的算法:1、Dijkstra邻接矩阵版,邻接链表版;2、Dijkstra+堆优化;3、解决图含负权含环的SPFA算法P4779 【模板】单源最短路径(标准版)题目描述给定n 个点,m 条有向边的带非负权图,请你计算从 s出发,到每个点的距离。数据保证你能从 s出发到任意点。输入格式第一行为 n, m, s三个正整数 。 第二行起行,每行三个非负整数u i,v i,w i ,表示从 u到 v有一条权值为w 的有向边。输出格式输出一行 n

2021-06-03 20:38:14 387

原创 P1090 [NOIP2004 提高组] 合并果子 / [USACO06NOV] Fence Repair G

题目描述在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆。多多决定把所有的果子合成一堆。每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和。可以看出,所有的果子经过 n−1 次合并之后, 就只剩下一堆了。多多在合并果子时总共消耗的体力等于每次合并所耗体力之和。因为还要花大力气把这些果子搬回家,所以多多在合并果子时要尽可能地节省体力。假定每个果子重量都为 1 ,并且已知果子的种类数和每种果子的数目,你的任务是设计出合并的次序方案,使多多耗费的体力最少

2021-05-29 21:13:50 425 2

原创 蓝桥杯真题:凑平方数

问题描述把 0 ~ 9 这 10 个数字,分成多个组,每个组恰好是一个平方数,这是能够办到的。比如:0,36,5948721再比如:{1098524736};{1,25,6390784};{0,4,289,15376}等等…注意,0 可以作为独立的数字,但不能作为多位数字的开始。分组时,必须用完所有的数字,不能重复,不能遗漏。如果不计较小组内数据的先后顺序,请问有多少种不同的分组方案?答案提交注意:需要提交的是一个整数,不要填写多余内容。答案:300思路:1、不要单纯的按照题目

2021-05-27 15:09:33 323

原创 P1162 填涂颜色

题目描述由数字0组成的方阵中,有一任意形状闭合圈,闭合圈由数字1构成,围圈时只走上下左右4个方向。现要求把闭合圈内的所有空间都填写成2.例如:6×6的方阵(n=6),涂色前和涂色后的方阵如下:0 0 0 0 0 00 0 1 1 1 10 1 1 0 0 11 1 0 0 0 11 0 0 0 0 11 1 1 1 1 10 0 0 0 0 00 0 1 1 1 10 1 1 2 2 11 1 2 2 2 11 2 2 2 2 11 1 1 1 1 1输入格式每组测试数据第

2021-05-17 16:46:42 130

原创 P1019 [NOIP2000 提高组] 单词接龙

题目背景注意:本题为上古 NOIP 原题,不保证存在靠谱的做法能通过该数据范围下的所有数据。题目描述单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的“龙”(每个单词都最多在“龙”中出现两次),在两个单词相连时,其重合部分合为一部分,例如 beast 和 astonish,如果接成一条龙则变为 beastonish,另外相邻的两部分不能存在包含关系,例如 at 和 atide 间不能相连。输入格式输入的第一行为一个单独的整数

2021-05-15 20:05:26 127

原创 P1605 迷宫

题目背景给定一个N*M方格的迷宫,迷宫里有T处障碍,障碍处不可通过。给定起点坐标和终点坐标,问: 每个方格最多经过1次,有多少种从起点坐标到终点坐标的方案。在迷宫中移动有上下左右四种方式,每次只能移动一个方格。数据保证起点上没有障碍。题目描述无输入格式第一行N、M和T,N为行,M为列,T为障碍总数。第二行起点坐标SX,SY,终点坐标FX,FY。接下来T行,每行为障碍点的坐标。输出格式给定起点坐标和终点坐标,问每个方格最多经过1次,从起点坐标到终点坐标的方案总数。输入输出样例输入 #12

2021-05-11 14:23:10 989

原创 P1433 吃奶酪

题目描述房间里放着n块奶酪。一只小老鼠要把它们都吃掉,问至少要跑多少距离?老鼠一开始在(0,0)点处。输入输出格式输入格式:第一行一个数n (n<=15)接下来每行2个实数,表示第i块奶酪的坐标。两点之间的距离公式=sqrt((x1-x2)(x1-x2)+(y1-y2)(y1-y2))输出格式:一个数,表示要跑的最少距离,保留2位小数。输入输出样例输入样例#1:41 11 -1-1 1-1 -1输出样例#1:7.41思路:1、搜索题+剪枝,思路和全排列相似,把

2021-05-10 16:12:12 347

原创 P1135 奇怪的电梯

题目描述呵呵,有一天我做了一个梦,梦见了一种很奇怪的电梯。大楼的每一层楼都可以停电梯,而且第ii层楼(1≤i≤N)上有一个数字Ki(0≤Ki≤N)。电梯只有四个按钮:开,关,上,下。上下的层数等于当前楼层上的那个数字。当然,如果不能满足要求,相应的按钮就会失灵。例如:3,3,1,2,5代表了Ki(K1=3,K2=3,…),从11楼开始。在1楼,按“上”可以到4楼,按“下”是不起作用的,因为没有−2楼。那么,从A楼到B楼至少要按几次按钮呢?输入格式共二行。第一行为33个用空格隔开的正整数,表示N,A,

2021-05-08 15:57:52 134

原创 C/C++左对齐,宽五格

左对齐,宽5格输出%5d是格式控制字符串,表示输出占5个字符的十进制整数,右对齐,不够用空格补齐。5是输出最小宽度,用于控制显示数值的宽度,是一个可选的指定最小值字段宽度的十进制数字字符串。如果转换值字符少于字段宽度,该字段将从左到右按指定的字段宽度填充。如果指定了左边调整选项,字段将在右边填充。如果转换结果宽于字段宽度,将扩展该字段以包含转换后的结果,不会发生截断。5前面是-则表示左对齐,无符号则默认为+右对齐。代码printf("%-5d",result[i][j]);...

2021-05-07 16:57:08 4483 4

原创 P2392 kkksc03考前临时抱佛脚

思路:1、使用DFS,罗列左右脑所有情况;计算最小时间,模拟左右脑,把一科不同的题目以不同的组合情况分给左右脑,左右脑用时最多一边的为该组合情况最后用时,然后记录不同组合的最小时间为一科所需要的最小时间,每科再相加。2、也可以用DP。我的代码:#include<cstdio>#include<algorithm>using namespace std;const int maxn = 10000000;int p[4],mintime = 0,minptime = .

2021-05-07 15:41:45 113

原创 P1219 [USACO1.5]八皇后 Checker Challenge

题目描述一个如下的 6 \times 66×6 的跳棋棋盘,有六个棋子被放置在棋盘上,使得每行、每列有且只有一个,每条对角线(包括两条主对角线的所有平行线)上至多有一个棋子。上面的布局可以用序列 2 4 6 1 3 5 2 4 6 1 3 5 来描述,第 ii 个数字表示在第 ii 行的相应位置有一个棋子,如下:行号 1 2 3 4 5 6 1 2 3 4 5 6列号 2 4 6 1 3 5 2 4 6 1 3 5这只是棋子放置的一个解。请编一个程序找出所有棋子放置的解。并把它们以上面的序列方

2021-05-06 19:01:07 177

原创 DFS全排列和组合问题(搜索篇)

全排列问题题目描述:把1~N这N个整数按不同的顺序摆放,输出所有可能的结果(按字典序从小到大)思路:1、先用数组hashtable记录每个数当前是否使用,未使用记0,使用过记1(是否在数组v中);用数组v记录全排列的顺序2、递归边界当下标等于N时输出数组v,return即可(如果难理解,可以在纸上用笔记录代码运行过程,多推几遍即可)我的代码:int n,v[20],hashtable[20] = {0};void DFS(int index){ if (index == n) {

2021-05-06 16:21:13 297

原创 CCF CSP 202012-2 期末预测之最佳阈值

题目背景考虑到安全指数是一个较大范围内的整数、小菜很可能搞不清楚自己是否真的安全,顿顿决定设置一个阈值 ,以便将安全指数 转化为一个具体的预测结果——“会挂科”或“不会挂科”。因为安全指数越高表明小菜同学挂科的可能性越低,所以当 时,顿顿会预测小菜这学期很安全、不会挂科;反之若 ,顿顿就会劝诫小菜:“你期末要挂科了,勿谓言之不预也。”那么这个阈值该如何设定呢?顿顿准备从过往中寻找答案。题目描述具体来说,顿顿评估了 位同学上学期的安全指数,其中第 ()位同学的安全指数为,是一个范围内的整数

2021-04-04 21:37:20 197

原创 PAT 1129 Recommendation System (25 分)

Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user’s preference by the number of times that an item has been accessed by this user.Input Spe

2021-03-03 19:21:13 142 1

原创 PAT 1052 Linked List Sorting (25 分)

A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you are supposed to sort the structures

2021-02-23 21:26:21 74

原创 PAT 1051 Pop Sequence (25 分)

Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we can obtain

2021-02-23 17:44:06 96

原创 CCF 201312-5 I’m stuck!

问题描述  给定一个R行C列的地图,地图的每一个方格可能是’#’, ‘+’, ‘-’, ‘|’, ‘.’, ‘S’, ‘T’七个字符中的一个,分别表示如下意思:  ‘#’: 任何时候玩家都不能移动到此方格;  ‘+’: 当玩家到达这一方格后,下一步可以向上下左右四个方向相邻的任意一个非’#‘方格移动一格;  ‘-’: 当玩家到达这一方格后,下一步可以向左右两个方向相邻的一个非’#‘方格移动一格;  ‘|’: 当玩家到达这一方格后,下一步可以向上下两个方向相邻的一个非’#‘方格移动一格;  ‘.’

2021-02-18 14:20:12 71

原创 PAT 1049 Counting Ones (30 分)

The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s in 1, 10, 11, and 12.Input Specification:Each input fil

2021-02-17 20:49:31 66

原创 PAT 1047 Student List for Course (25 分)

Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input Specification:Each input file contains one test case. For

2021-02-17 13:40:02 49

原创 PAT 1046 Shortest Distance (20 分)

The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contains one test case. For each case, the first line contains

2021-02-17 11:47:23 52

原创 PAT 1044 Shopping in Mars (25 分)

Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any position for only once and some of the diamonds are taken off the

2021-02-16 12:20:36 64

原创 PAT 1043 Is It a Binary Search Tree (25 分)

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The right subtree of a node contains only nodes with keys greater than

2021-02-15 17:44:16 64

原创 迭代器运用注意事项

1、vector,string,deque支持直接对迭代器进行加减某个数字,如str.begin() + 3;而map,set则不支持2、对容器元素访问时,除开vector和string之外的STL容器都不支持*(it + i)的访问方式

2021-02-14 10:47:37 161

原创 PAT 1038 Recover the Smallest Number (30 分)

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229-87 or 0229-32-87-321-3214 with respect to different ord

2021-02-14 10:03:01 57

原创 PAT 1034 Head of a Gang (30 分)

One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls made between

2021-02-11 11:30:40 85

原创 PAT 1033 To Fill or Not to Fill (25 分)

With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked to car

2021-02-09 10:15:59 67 1

原创 PAT 1032 Sharing (25 分)

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 example, loading and being are stored as showed in Figure 1.Fig

2021-02-07 11:49:20 52

原创 PAT 1025 PAT Ranking (25 分)

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 ranklists will be merged immediately after the test. Now it is your

2021-02-05 22:13:46 55

原创 PAT 1023 Have Fun with Numbers (20 分)

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a diffe

2021-02-05 09:35:06 66

原创 PAT 1022 Digital Library (30 分)

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 assigned an unique 7-digit number as its ID. Given any query from a reader, you are suppose

2021-02-04 13:11:57 61

原创 PAT 1021 Deepest Root (25分)

A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root is called the deepest root.Input Specification:Each in

2021-02-04 09:36:45 43

原创 PAT 1020 Tree Traversals (25分)

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 tree.Input Specification:Each input

2021-01-14 21:03:42 89

原创 PAT 1019 General Palindromic Number (20分)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Although palindromic numbers are most often considered

2021-01-09 20:41:52 54

原创 PAT 1016 Phone Bills (25分)

A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the t

2021-01-01 20:10:05 103

原创 PAT 1015 Reversible Primes (20分)

A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime.Now given any two positive integers N (<10^5 ) a

2020-12-29 20:51:25 73

原创 PAT 1013 Battle Over Cities (25分)

It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any other highways to keep the rest of the c

2020-12-29 19:59:06 93

原创 PAT 1012 The Best Rank (25分)

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, we encourage students by emphasi

2020-12-27 02:41:08 195

原创 PAT 1010 Radix (25分)

Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers N1 and N2, your task is to find the radix of one num

2020-12-25 21:47:05 81

原创 PAT 1009 Product of Polynomials (25分)

This time, you are supposed to find A×B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:K N1 aN1 N2 aN2… N​K aN​K where K is

2020-12-23 21:08:55 55

原创 PAT 1006 Sign In and Sign Out (25分)

At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, you are supposed to find the ones who have unlocked and loc

2020-12-22 22:12:01 61

计算机毕业设计:基于数据可视化的算法教学演示软件的设计与实现(实现了八种排序算法的可视化)

基于数据可视化的算法教学演示软件的设计与实现,设计并实现直观、容易被理解的算法的动态演示软件,是课题研究的目的。随着计算机技术的不断发展,人们提出了各种算法,对于算法思路的理解非常关键。然而,传统的算法学习基于纸面的程序代码或者文字描述,对于学习者来说,不直观、不易理解。本毕设软件旨在开发一套具有可视化界面的算法演示软件,从算法的设计思路、实现过程、性能评价等角度对算法进行动态演示。相比于传统方法具有直观、易理解等特点,方便学习。 包含python软件开发源码{使用了matplotlib模块)开题报告,中期检查,论文,答辩ppt。由于网上这类软件资源很少,仅供学习者学习参考。

2022-05-24

个人博客前端模板,各种风格,168套任意选

HTML个人博客前端模板,各种风格,168套任意选,大量减轻敲代码时间,高效开发个人博客网站,总有一款适合你。

2022-05-20

空空如也

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

TA关注的人

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