自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 算法笔记

目录基础数学问题质因子分解例题基础数学问题质因子分解质因子分解是指将一个正整数n写成一个或多个质数的乘积的形式。思路:可以先把素数表打印出来定义一个结构体数组factor用来存放质因子struct factor{ int x,cnt; //x为质因子,cnt为其个数}fac[10];思路枚举1到sqrt(n)的所有质因子p,判断p是否是n的因子,是则加入,不是跳过 如果最后的n不等于1,说明有一个大于sqrt(n)的质因子,也要加入例题1096

2021-02-02 11:52:48 118

原创 TP框架的Container容器类源码分析

TP框架的Container源码分析版本:5.1.39TLSContainer的结构导图Container结构图Container中的属性$instance——用于容器自身实例化 $instances——一个用于存放容器中的对象实例的数组 $name——容器表示别名 $bind——容器绑定标识$bind的初始值 /** * 容器绑定标识 * @var array */ protected $bind = [ 'a

2020-08-22 15:22:46 796

原创 fastadmin开发插件的基本流程

什么是fastadmin?FastAdmin是一款基于ThinkPHP5+Bootstrap的极速后台开发框架。fastadmin开发基础管理插件步骤以一个学校管理插件为例开发环境与工具PHPSTORMphpstudynginx1.15.11mysql8.0php7.3.4准备工作配置站点我的域名设置为fast51admin.localhost....

2020-05-02 11:12:31 3942 1

原创 Mysql的B+树索引

目录MySQL索引机制索引的本质索引的目标索引的工作流程wMySQL支持的索引的数据结构hash索引B+树索引为什么MySQL选择B+树作为索引的数据结构平衡二叉搜索树使用平衡二叉搜索树的弊端B-树(多路平衡树)发散思考为什么不是什么字段都适合添加索引为什么MySQL推荐我们使用自增id作为主键索引B+树(B-树加强版)I/O能力强于...

2020-01-06 16:11:46 354 1

原创 kmp算法

#include <iostream>#include <string>#include <vector>using namespace std;int nexts[100];int Index_KMP(string s,string t,int pos){ int sl=s.size(); int tl=t.size(); int i=pos; int j=0; while(i<sl&&j.

2021-03-12 17:54:27 202

原创 1039 Course List for Student

Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query.Input Specification:Each input file cont

2021-02-07 23:14:37 183

原创 1024 Palindromic Number

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 are palindromic numbers.Non-palindromic numbers can be paired with palindromi.

2021-02-03 21:33:52 188

原创 1023 Have Fun with Numbers

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-03 20:30:06 114

原创 1059 Prime Factors

Given any positive integerN, you are supposed to find all of its prime factors, and write them in the formatN=p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​k​m​​​​.Input Specification:Each input file contains one test case which gives a positive integerNin...

2021-02-02 13:10:26 67

原创 1096 Consecutive Factors

Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, you are supposed to find the maximum num

2021-02-02 11:51:05 85

原创 1015 Reversible Primes (20分)

Areversible primein 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 integersN(<10​5​​)...

2021-01-31 17:01:15 68

原创 1078 Hashing (25分)

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to beH(key)=key%TSizewhereTSizeis the maximum size of the hash table. Qua...

2021-01-31 15:17:48 71

原创 1081 Rational Sum (20分)

GivenNrational numbers in the formnumerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integerN(≤100), followed in the next lineNrational numb...

2021-01-26 20:47:40 80 1

原创 1008 Elevator (20分)

The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to..

2021-01-25 19:06:55 64

原创 1101 Quick Sort (25分)

There is a classical process namedpartitionin 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 pivot to its right. GivenN...

2021-01-25 09:20:41 71

原创 93 Count PAT‘s (25分)

The stringAPPAPTcontains twoPAT'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 supposed to tell the number of...

2021-01-24 21:52:38 93 1

原创 王道——顺序表编程题

1.从顺序表中删除具有最小值的元素(假设唯一)并有函数返回被删元素的值。空出的位置由最后一个元素填补,若顺序表为空则显示出错信息并退出运行。struct ll{ int nums[10]= {1,3,4,9,7,5,2,6,8,0}; int length=10; int max_size=10; int del_min() { if(length==0) { cout<<"顺序表为空".

2021-01-17 17:52:32 806

原创 1029 Median (25分)

1029Median(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 is d..

2021-01-15 21:52:14 106

原创 1089 Insert or Merge (25分)

According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, a.

2021-01-15 21:30:16 78

原创 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 requirement of the payment: for eac

2021-01-14 16:54:08 85

原创 快速幂模板

递归版本typedef long long ll;//求a^b%m得快速幂的递归写法ll binaryPow(ll a,ll b,ll m){ if(b==0) return 1; //如果b为0,那么a^0=1; //b为奇数,转为b-1 if(b&1) //替换b%2==1,位与操作速度更快 return a*binaryPow(a,b-1)%m; else{ //b为偶数,转为b/2 ll m

2021-01-14 11:27:14 79

原创 解决寻找有序序列第一个满足某条件的元素的位置的固定模板(二分思想)

//解决“寻找有序序列第一个满足某条件的元素的位置”问题的固定模板//二分区间为[left,right],初值必须能覆盖解的所有可能取值int solve(int left,int right){ int mid; while(left<right) { mid=(left+right)/2; if(条件成立) //第一个满足该条件的元素的位置<=mid { right=mid;//搜左区..

2021-01-14 10:08:04 97

原创 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 ifSwap(0, *)is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may apply the swap operations in the followin...

2021-01-13 16:01:55 87

原创 1037 Magic Coupon (25分)

The magic shop in Mars is offering some magic coupons. Each coupon has an integerNprinted on it, meaning that when you use this coupon with a product, you may getNtimes the value of that product back! What is more, the shop also offers some bonus produ...

2021-01-13 14:28:11 94

原创 1005 Spell It Right (20分)

Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies one line which contains anN(≤10​100​​)...

2021-01-10 21:12:20 96 1

原创 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-01-10 20:53:58 58

原创 王道数据结构错题总结——第一章

1.可以用(抽象数据类型)定义一个完整的数据结构。解析:抽象数据类型(ADT)描述了数据的逻辑结构和抽象运算,通常用(数据对象,数据关系,基本操作集)这样的三元组来表示,从而构成一个完整的数据结构定义。2.数据的逻辑结构独立于其逻辑结构。解析:数据的逻辑结构是从面向实际问题的角度出发的,只采用抽象表达方式,独立于存储结构,数据的存储方式有多种不同的选择;而数据的存储结构是逻辑结构在计算机上的映射,它不能独立于逻辑结构二存在。3.对于不同的数据结构,逻辑结构和物理结构可以完全相同。

2021-01-10 18:41:06 1219

原创 java复习整理——第4章

继承子类重写父类时不能定比它更高的访问权限super关键字可以访问父类的成员变量和成员方法在子类的构造方法中可以使用这个关键字访问父类的构造方法final关键字特性final修饰的类不能被继承 final修饰的方法不能被子类重写 final修饰的变量是常量,只能赋值一次抽象类当定义方法但不写方法体时可以定义为抽象类,关键字是abstract。抽象方法一定在抽象类中,但抽象类不一定有抽象方法接口函数型接口只有一个抽象方法使用接口的目的是克服单继承的限制,一

2020-12-27 20:33:18 71

原创 java复习整理——第三章

面向对象的三个特性封装性、继承性、多态性对象定义A a = new A();变量a的内存中存放A对象的内存地址,即指向对象A变量为null表示该变量不指向任何对象构造方法满足条件:方法名与类名相同,在方法名的前面没有返回值类型的声明,在方法中不能使用return语句返回一个值,但是可以单独写return语句作为方法的结束。this关键字指代当前对象可以在一个类的构造方法中使用this(参数1,参数2...)的方式调用其他构造方法但要注意只能在构造方法中使用t

2020-12-27 17:26:54 732

原创 java复习整理——第二章

java中的常量整型常量 浮点数常量——单精度末尾以F或f结尾,双精度末尾以D或d结尾,不加默认是double型 字符常量,Java采用Unicode字符集 字符串常量 布尔常量 null常量java中的变量类型基本数据类型:整数类型,浮点类型,字符型,布尔型引用数据类型:类,接口,数组,枚举,注解整数类型——byte,short,int,longbyte占8个字节,给long赋值时要在后面加上L(l)后缀(如果数据长度超过int的话)浮点数类型——double,f.

2020-12-27 15:33:17 196

原创 算法分析与设计(王秋芬)(1)——贪心法

贪心法贪心法的基本思想每个阶段面临选择时,贪心法都做出对眼前情况的最优解,不考虑后续影响。 每个阶段的决策一旦做出,不可以更改,不能回溯 贪心法是根据贪心策略来逐步构造问题的解,策略不同结果不同 贪心法具有高效性和不稳定性,它可以很快得到解,但不一定是最优解。贪心算法的好坏关键在于贪心策略的选择贪心法的基本要素(适合的问题)最优子结构性质——当一个问题的最优解一定包含其子问题的最优解时,则该问题具有最优子结构性质 贪心选择性质——所求问题的整体最优解可以通过一系列局部最优的选择获得

2020-12-17 20:30:45 698

原创 1004 Counting Leaves (30分)

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts with a line containing0<N<100, the number of nod.

2020-12-11 09:56:58 68

原创 1003 Emergency (25分)——迪杰斯特拉模板题

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked

2020-12-10 09:46:55 181

原创 最短路算法——Dijkstra以及它的优化

示例图代码#include <iostream>#include <math.h>#include <algorithm>#include <stdlib.h>#include <stdio.h>#include <iomanip>#include <string.h>#include <vector>#include <set>#include <map>

2020-12-09 20:55:59 151

原创 算法分析与设计(王秋芬)(1)——算法及基础知识

算法及基础知识算法的定义与特性定义:指的是对特定问题求解步骤的一种描述,是若干指令的有穷指令特性:输入——有零个或多个输入,来源于外界提供或自己产生 输出——有一个或多个输出 确定性——组成算法的每条指令必须有确定的含义,无歧义 有限性——算法中每条指令的执行次数都是有限的,执行每条指令的时间也是有限的 可行性——一个算法是可行的,即算法中描述的操作都可以通过已经实现的基本运算执行有限次后实现算法的描述方式:常用的描述方式有自然语言、图形、程序设计语言、伪代码等算法与程序的区别

2020-12-09 16:43:40 1268

原创 1002 A+B for Polynomials (25分)

This time, you are supposed to findA+BwhereAandBare 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:KN​1​​a​N​1​​​​N​2​​a​N​2​​​​...

2020-12-08 08:06:53 148

原创 1075 链表元素分类 (25分)

定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而 [0, K] 区间内的元素都排在大于 K 的元素前面。但每一类内部元素的顺序是不能改变的。例如:给定链表为 18→7→-4→0→5→-6→10→11→-2,K 为 10,则输出应该为 -4→-6→-2→7→0→5→10→18→11。输入格式:每个输入包含一个测试用例。每个测试用例第 1 行给出:第 1 个结点的地址;结点总个数,即正整数N (≤10​5​​);以及正整数K (≤10​3​​)。结点的地址是 5

2020-12-04 16:57:23 101

原创 1072 开学寄语 (20分)

下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面、理发、整衣,然后思过、读书、锻炼、明智、开悟、精进。而后必成大器也!本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器。输入格式:输入第一行给出两个正整数 N(≤1000)和 M(≤6),分别是学生人数和需要被查缴的物品种类数。第二行给出 M 个需要被查缴的物品编号,其中编号为 4 位数字。随后 N 行,每行给出一位..

2020-12-04 09:44:46 176

原创 1064 朋友数 (20分)

如果两个整数各位数字的和是一样的,则被称为是“朋友数”,而那个公共的和就是它们的“朋友证号”。例如 123 和 51 就是朋友数,因为 1+2+3 = 5+1 = 6,而 6 就是它们的朋友证号。给定一些整数,要求你统计一下它们中有多少个不同的朋友证号。输入格式:输入第一行给出正整数 N。随后一行给出 N 个正整数,数字间以空格分隔。题目保证所有数字小于10​4​​。输出格式:首先第一行输出给定数字中不同的朋友证号的个数;随后一行按递增顺序输出这些朋友证号,数字间隔一个空格,且行末不得有多.

2020-12-02 20:44:18 146

原创 1065 单身狗 (25分)

“单身狗”是中文对于单身人士的一种爱称。本题请你从上万人的大型派对中找出落单的客人,以便给予特殊关爱。输入格式:输入第一行给出一个正整数 N(≤50 000),是已知夫妻/伴侣的对数;随后 N 行,每行给出一对夫妻/伴侣——为方便起见,每人对应一个 ID 号,为 5 位数字(从 00000 到 99999),ID 间以空格分隔;之后给出一个正整数 M(≤10 000),为参加派对的总人数;随后一行给出这 M 位客人的 ID,以空格分隔。题目保证无人重婚或脚踩两条船。输出格式:首先第一行输..

2020-12-02 20:20:25 176

空空如也

空空如也

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

TA关注的人

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