自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 PAT甲级-1022 Digital Library (30 分)

//A1022 Digital Library (30 分)#include <stdio.h>#include <iostream>#include <set>#include <map>using namespace std;const int maxn= 10010;int n, m;map<string, set<string> > search[6];int main(){ scanf("%d", &am

2022-03-02 22:09:36 109

原创 PAT-A1112 Stucked Keyboard (20分)

题目描述:On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times.Now given a resulting string on screen, you are supposed to list all

2020-07-03 23:17:35 157

原创 PAT-A1117 Eddington Number (25分)

题目描述:British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an “Eddington number”, E – that is, the maximum integer E such that it is for E days that one rides more than E miles. Eddington’s

2020-06-29 21:36:50 3398

原创 结构体用于set时符号的重载和简单的赋值方式

1.总体struct itemID{ int value; //编号 int num; //出现频率 itemID(int a, int b): value(a), num(b){} bool operator < (const itemID &a) const{ return (num != a.num) ? num > a.num : value < a.value; } };2.符号的重载//结构体的名称是itemIDbool operator &

2020-06-05 12:03:19 359

原创 PAT-A1128 N Queens Puzzle (20分)

题目描述:The “eight queens puzzle” is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal. The eight queens puzzle is an

2020-06-03 21:26:42 162

原创 PAT-A1137 Final Grading (25分)

题目描述:For a student taking the online course “Data Structures” on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from the online programming assignments, and then rece

2020-05-24 20:12:51 152

原创 PAT-A1136 A Delayed Palindrome (20分)

题目描述:Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​ ⋯a​1​​a​0​​ with 0≤ a​i​​ <10 for all i and a​k​​ >0. Then N is palindromic if and only if a​i​​ =a​k−i​​ for all i. Zero is written 0 and is also pali

2020-05-22 16:35:58 166

原创 PAT-A1143 Lowest Common Ancestor (30分)

题目描述:The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a nod

2020-05-21 22:50:28 147

原创 PAT-A1142 Maximal Clique (25分)

题目描述:A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. (Quoted from https://en.wikipedia.or

2020-05-20 13:40:20 122

原创 PAT-A1140 Look-and-say Sequence (20分)

题目描述:Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, …where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number. For example, the 2nd number means that there is o

2020-05-19 10:41:12 162

原创 PAT-A1147 Heaps (30分)

题目描述:In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to (in a min h

2020-05-18 17:33:32 141

原创 PAT-A1146 Topological Order (25分)

题目描述:This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test each of the options.输入格式:Each input file conta

2020-05-18 15:12:23 166

原创 哈希算法中的二次探测法(正向)

假设数组hashTable的长度是mSize,用平方探测法插入数字num,每次的位置pos = (num + i * i) % mSize,i的范围是[0, mSize)。bool flag = false; //未插入for(int i = 0; i < mSize; i++){ int pos = (num + i * i) % mSize; if(hashTable[pos] == 0){ hashTable[pos] = num; flag = true; //已插入 br

2020-05-18 09:36:45 1931

原创 PAT-A1144 The Missing Number (20分)

题目描述:Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.输入格式:Each input file contains one test case. For each case, the first line gives a positive integer N (≤10​5​​ ). Then N integers are given in

2020-05-12 21:44:51 132

原创 PAT-A1151 LCA in a Binary Tree (30分)

题目描述:The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.输入格式:Each input file contains one test case. For each

2020-05-12 21:03:54 154

原创 PAT-A1150 Travelling Salesman Problem (25分)

题目描述:The “travelling salesman problem” asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origin city?” It is an NP-hard problem

2020-05-11 13:30:59 152

原创 Python-Networks and Sockets(课堂笔记整理)

利用socket读取网页信息import socketmysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)mysock.connect(('data.pr4e.org', 80))cmd = 'GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n'.encode(...

2020-05-08 12:43:55 306 1

原创 Python-Regular Expressions(课堂笔记整理)

1.调用库函数import re2.常用的正则表达式3.举例1)Using re.search() Like find()find()形式hand = open('mbox-short.txt')for line in hand: line = line.rstrip() if line.find('From:') >= 0: print(line)re.sea...

2020-05-06 22:30:03 463

原创 Python-tuple(课堂笔记整理)

Tuple是受限制的List1.Tuple和List的区别:1)形式上的区别:()与[]x = ('Sally', 'John', 'Leo') # Tupley = ['Sally', 'John', 'Leo'] # List2)使用时的区别Tuple初始化后无法被更改,像Str一样# List初始化后可以被更改x = [9, 8, 7]x[2] = 6print(x)...

2020-05-02 22:21:44 212

原创 Python-dictionary(课堂笔记整理)

Dictionaries are like bags - no orderpurse = dict()purse['money'] = 12purse['candy'] = 3purse['tissues'] = 75print(purse)# {'money': 12, 'tissues': 75, 'candy': 3}print(purse['candy']) # 3purs...

2020-05-01 16:34:22 388

原创 Python - list (课堂笔记整理)

Building a List from Scratchstuff = list() # an empty liststuff.append('book') # add an elementstuff.append(99)print(stuff)# ['book', 99]stuff.append('cookie')print(stuff)# ['book', 99, 'coo...

2020-04-29 15:33:40 138

原创 Python读取txt文件的4种情形

1.以行读取文件:xfile = open('mbox.text')cnt = 0 #统计共有几行for cheese in xfile : print(cheese) #每次打印一行 cnt = cnt + 1print('Line count:', cnt)2.以单个

2020-04-29 13:00:28 455

原创 Java初学-1.计算

Scanner in = new Scanner(System.in);Math.abs(a - b) < 1e-6 //浮点数的比较

2020-03-07 15:40:18 115

原创 PAT-A1007 Maximum Subsequence Sum (25分)

1007 Maximum Subsequence Sum (25)(25 分) Given a sequence of K integers { N~1~, N~2~, …, N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, …, N~j~ } where 1 &amp;lt;= i &amp;lt;= j &amp;lt;= K. Th...

2018-08-25 16:47:45 153

空空如也

空空如也

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

TA关注的人

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