自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(56)
  • 收藏
  • 关注

原创 正则表达式

,那么正则表达式也是与之类似的用来进行文本匹配的工具,只不过比起通配符正则表达式更强大,它能更精确地描述你的需求(当然你付出的代价是书写一个正则表达式比打出一个通配符要复杂得多,要知道任何给你带来好处的东西都是有代价的,就如同学习一门编程语言一样),比如你可以编写一个正则表达式,用来查找所有以0开头,后面跟着2-3个数字,然后是一个连字号“-”,最后是7或8位数字的字符串(像028-12345678或0813-7654321),这不就是国内的座机号码吗。如果需要为flags参数指定多个值,可以使用。

2024-04-14 19:05:16 790

原创 基于ChatGPT的智能问答、ai绘图微信小程序思路

利用openai的开放api设计一款随时随地使用的chatgpt微信小程序

2023-03-22 14:54:22 5336

原创 集体照排序问题PAT A1109

问题1109 Group Photo (25 分)Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following:The number of people in each row must be N/K (round down to the nearest integer), with all the extra people

2021-08-29 19:12:43 154

原创 sscanf和sprintf的应用

问题1108 Finding Average (20 分)The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000] a

2021-08-28 15:36:57 123

原创 图的BFS

问题分别用邻接矩阵和邻接表实现图的BFS算法邻接矩阵//邻接矩阵版int n,G[maxn][maxn];bool vis[maxn] = {false};void BFS(int u){ queue<int> q; q.push(u); inq[u] = true; while (!q.empty()){ int u = q.front(); q.pop(); for (int v = 0; v &l

2021-08-28 11:26:53 95

原创 图的DFS

问题分别用邻接表和邻接矩阵实现图的DFS算法邻接矩阵//邻接矩阵版本int n,G[maxn][maxn];bool vis[maxn] = {false};void DFS(int u,int depth){ //u为当前访问的顶点编号,depth为深度 vis[u] = true; //如果需要对 u 进行一些操作,可以在这里进行 //下面对所有从 u 出发能到达的顶点进行枚举 for (int v = 0; v < n; ++v) {

2021-08-28 11:00:21 174

原创 AOE网关键路径长度求解的实现

问题在一个有向无环图中,求解关键路径以及其长度。思路1.按拓扑排序和逆拓扑排序分别计算各顶点的(事件)的最早发生时间和最迟发生时间。2.用上面的结果计算各边的(活动)的最早开始时间和最迟开始时间。3.e[i->j] = l[i->j]的活动即为关键活动。代码#include <bits/stdc++.h>using namespace std;int n,m;const int maxn = 1010;struct node{ int v; in

2021-08-28 10:17:37 791

原创 求两个集合交集与并集的元素个数比例

问题1063 Set Similarity (25 分)Given two sets of integers, the similarity of the sets is defined to be Nc​/Nt​×100%, where Nc​is the number of distinct common numbers shared by the two sets, and Nt​is the total number of distinct numbers in the

2021-08-09 11:47:45 725

原创 分数相加问题

问题1081 Rational Sum (20 分)Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integer N (≤100), followed in the

2021-08-08 10:23:04 58

原创 计算电梯耗时问题

问题1008 Elevator (20 分)The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one

2021-08-07 16:33:32 83

原创 简单数学题

问题1104 Sum of Number Segments (20 分)Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3,

2021-08-07 16:14:11 102

原创 数字黑洞问题

问题1069 The Black Hole of Numbers (20 分)For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by taking the second nu

2021-08-07 00:07:33 87

原创 快速排序确定枢轴

问题1101 Quick Sort (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its left and those larger than the p

2021-08-06 23:17:51 512

原创 在字符串中特定字串的数量

问题1093 Count PAT’s (25 分)The string APPAPT contains two PAT’s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now given any string, you are supp

2021-08-06 22:44:49 89

原创 寻找两个序列的中位数

问题1029 Median (25 分)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, 15, 16, 17 } is 15. The median of two sequences i

2021-08-06 22:19:01 178

原创 二分查找的简单应用

问题1085 Perfect Sequence (25 分)Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respectively.Now given a sequen

2021-08-05 23:55:01 53

原创 贪心算法巩固

问题1067 Sort with Swap(0, i) (25 分)Given any permutation of the numbers {0, 1, 2,…, N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may apply t

2021-08-05 22:41:21 65

原创 乘积最大值(贪心思想)

问题给出两个集合,各选出n个元素,求乘积最大值、1037 Magic Coupon (25 分)The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back!

2021-08-05 21:36:52 757

原创 贪心思想简单题(出售月饼)

问题1070 Mooncake (25 分)Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region’s culture. Now given the inventory amounts and

2021-08-05 17:32:18 77

原创 散列表空间换时间

问题1048 Find Coins (25 分)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requireme

2021-08-05 17:08:07 119

原创 字符串的匹配

问题1050 String Subtraction (20 分)Given two strings S1​and S2​, S=S1​−S2​is defined to be the remaining string after taking all the characters in S2​from S1​. Your task is simply to calculate S1​−S2​for any given strings. However, i

2021-08-05 11:37:54 59

原创 散列表的运用

问题1092 To Buy or Not to Buy (20 分)Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in who

2021-08-05 10:43:28 42

原创 1012 The Best Rank 排序问题

问题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

2021-08-03 14:31:42 69

原创 sort排序常见排名题

问题1062 Talent and Virtue (25 分)About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people’s talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a “sage(圣人)”

2021-08-03 12:12:45 250

原创 找字符串的最长后缀

问题1077 Kuchiguse (20 分)The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personality. Such a preference is called “Kuchiguse” and is often exagge

2021-08-03 00:13:03 179

原创 密码易混淆字符替换去歧义问题

问题1035 Password (20 分)To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from

2021-08-02 22:28:39 113

原创 字符串的处理

问题1061 Dating (20 分)Sherlock Holmes received a note with some strange strings: Let’s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings are actually referring to the cod

2021-08-02 18:35:52 50

原创 两个点分进制数的相加

问题1058 A+B in Hogwarts (20 分)If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it’s easy enough.” Y

2021-08-02 12:10:07 56

原创 巧解进制转换题

问题1027 Colors in Mars (20 分)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 for Red, the middle 2 digits for Green, and the las

2021-08-02 11:47:16 74

原创 图形输出题

问题1031 Hello World for U (20 分)Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:h de ll rlowoThat is, the characters must be printed in the original order,

2021-08-01 23:54:18 51

原创 进制转换简单题

问题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 pal

2021-08-01 23:22:23 116

原创 简单的排序模拟题

问题1036 Boys vs Girls (25 分)This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one test case. Each case contains

2021-08-01 22:46:15 93

原创 sort排序问题

问题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 fin

2021-08-01 20:20:37 188

原创 多项式相乘

问题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

2021-08-01 19:09:00 234

原创 多项式相加

问题1002 A+B for 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

2021-08-01 17:18:49 97

原创 大整数的相加和大小判断

问题1065 A+B and C (64bit) (20 分)Given three integers A, B and C in [−263,263], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the positive number of test cases, T (≤10). Then T test cases follow, each

2021-08-01 12:34:29 80

原创 简单的全源最短路径

问题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 ea

2021-08-01 11:07:21 52

原创 扑克牌模拟算法题

问题1042 Shuffling Machine (20 分)Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate with gamblers by performing inadequ

2021-08-01 10:21:01 146

原创 拓扑排序的实现(基于邻接表实现)

问题给出一个DAG,按事情的先后顺序给事件排序。思路利用队列,将所有入度为0的结点加入队列。队首元素出队,去除从该元素引出的边,相应的结点入度减一,如果减完后,结点入度为0,则加入队列。代码#include<bits/stdc++.h>using namespace std;const int maxn = 1000;vector<int> G[maxn];int n,m,inDegree[maxn];bool topologicalSort(){ i

2021-07-31 23:19:53 321

原创 prim算法解决亚历山大攻打恶魔大陆问题

问题求最小生成树的边权之和思路参考dijkstra算法的思路,更改d[]的含义,并且更新d[]的条件有一些不同。代码#include<bits/stdc++.h>using namespace std;const int maxn = 1000;const int INF = 1000000000;int d[maxn];int G[maxn][maxn];bool vis[maxn] = {false};int n,m;int prim(){ //默认0号为初

2021-07-31 22:26:48 74

空空如也

空空如也

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

TA关注的人

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