原创 【數字圖像處理】二維(2D)線性插值的應用

應用情況 在使用matlab對圖像進行各種操作的時候經常要使用插值進行計算。 例如:圖像縮放、圖像旋轉、仿射變換等等。 線性插值 先介紹線性插值的概念。 已知兩個點(x1, y1)、(x2, y2),求它們中間橫座標爲x的點的y值。 則

原创 【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 i

原创 【算法筆記】二分法的使用(使用目的+模板)

今天看完《算法筆記》裏二分法這個章節,稍微總結一下。 二分法的思想主要就是折半查找,達到O(logn)的查找速度。 使用目的或者說使用情景主要有如下三個,下面將依次介紹。 查找有序序列中是否存在滿足條件的元素 查找有序序列中滿足條件的第一

原创 【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

原创 【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 

原创 【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(

原创 【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 {

原创 【算法筆記】散列(hash)總結

有兩天沒寫博客了,前兩天刷完了PAT甲級中的散列的題目,做一個小小的總結。 散列的定義: 將元素通過一個函數轉化成一個整數,使得該整數能夠儘量唯一地代表這個元素。 最常用的散列: 對於數字而言,H(key) = key,最常見的用法是某個

原创 【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 yo

原创 【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

原创 【PAT甲級】1095 Cars on Campus

Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate num

原创 【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

原创 【PAT乙級】1090 危險品裝箱

集裝箱運輸貨物時,我們必須特別小心,不能把不相容的貨物裝在一隻箱子裏。比如氧化劑絕對不能跟易燃液體同箱,否則很容易造成爆炸。 本題給定一張不相容物品的清單,需要你檢查每一張集裝箱貨品清單,判斷它們是否能裝在同一只箱子裏。 輸入格式: 輸入

原创 【PAT甲級】1012 The Best Rank

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C -

原创 【PAT甲級】1075 PAT Judge

The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are sup