4 Y_CanFly




TA的排名 9w+

【PAT甲级】1029 Median

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...

2019-09-29 10:58:23


推免到今天也终于告一段落啦,答应达仔写了复试机试的题目,其实都是很简单的题,测试用例也是老师手动输入的,没有极端样例,一共两题,一题10分。第一题在一行内输入数个字符串,每个字符串用空格隔开,求输出所有字符串的最大前缀子串(区分大小写),如果前缀子串不存在,则输出None。Example1输入:Word World WorlExample1输出:WorExam...

2019-09-28 11:09:39


Java装了好几次,每次都要重新找环境变量的设置,在此记录一下。1. 下载JDK可以在Java下载最新版的JavaSE安装包https://www.oracle.com/technetwork/java/javase/downloads/index.html截止到目前,最新版已经更新到JDK12可以选择直接下载JDK或者exe安装安装后可以找到JDK文件目录2....

2019-03-27 23:01:14


快速幂的递归法// 求a^b%m ll binaryPow(ll a, ll b, ll m) { if (b == 0) return 1; if (b %2 == 1) { return a * binaryPow(a, b-1, m) % m; } else { ll tmp = binaryPow(a, b/2, m); return tmp * tmp % m...

2019-02-18 09:45:58


假期稍微回顾一下一些经典问题的写法说明:N皇后问题遍历的话太耗时间,因此使用回溯法解决代码#include <cstdio>#include <cmath>#include <iostream>#define ll long longusing namespace std;const int maxn = 16;bool hash...

2019-02-18 09:21:52



2018-11-17 22:33:28


应用情况在使用matlab对图像进行各种操作的时候经常要使用插值进行计算。例如:图像缩放、图像旋转、仿射变换等等。线性插值先介绍线性插值的概念。已知两个点(x1, y1)、(x2, y2),求它们中间横坐标为x的点的y值。则可以利用如下公式进行插值计算。其中a和(1-a)为x距离x1和x2的距离占(x2-x1)的比例。y = a*y1 + (1-a)*y2线...

2018-11-17 21:33:38

【PAT甲级】1085 Perfect Sequence(二分法)

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 Mand m are the maximum and minimum numbers in the sequence, respectiv...

2018-11-13 20:01:12

【PAT甲级】1044 Shopping in Mars(二分法)

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 ...

2018-11-13 19:45:15

【PAT甲级】1010 Radix(二分法)

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 inte...

2018-11-13 19:27:35


今天看完《算法笔记》里二分法这个章节,稍微总结一下。二分法的思想主要就是折半查找,达到O(logn)的查找速度。使用目的或者说使用情景主要有如下三个,下面将依次介绍。查找有序序列中是否存在满足条件的元素 查找有序序列中满足条件的第一个元素 对一些函数进行求根(近似)计算1. 查找有序序列中是否存在满足条件的元素下面的函数是找到a[]数组中是否有等于x的元素,如果有返回索引下标...

2018-11-12 21:56:31

【PAT甲级】1070 Mooncake(贪心)

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 ...

2018-11-07 15:07:18

【PAT甲级】1067 Sort with Swap(0, i)(贪心)

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...

2018-11-07 14:57:57

【PAT甲级】1038 Recover the Smallest Number(贪心+排序)

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...

2018-11-07 12:37:00

【PAT甲级】1037 Magic Coupon(贪心)

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 b...

2018-11-06 21:33:31

【PAT甲级】1033 To Fill or Not to Fill(贪心)

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 ga...

2018-11-06 21:01:09


有两天没写博客了,前两天刷完了PAT甲级中的散列的题目,做一个小小的总结。散列的定义:将元素通过一个函数转化成一个整数,使得该整数能够尽量唯一地代表这个元素。最常用的散列:对于数字而言,H(key) = key,最常见的用法是某个数字直接作为对于数组的下标。比如标记某个数字num(0 <= num <= 10000)是否出现过,可以直接映射到bool数组vis[10...

2018-11-05 15:39:53

【PAT甲级】1092 To Buy or Not to Buy(散列)

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 sel...

2018-11-02 13:39:13

【PAT甲级】1084 Broken Keyboard(散列)

On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to...

2018-11-02 13:31:27

【PAT甲级】1050 String Subtraction(散列)

Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply to calculate S​1​​−S​2​​ for any given s...

2018-11-02 13:21:06


勋章 我的勋章
  • 持之以恒
  • 1024勋章
  • 勤写标兵Lv1