OJ
Physicaloser
博客主页:https://zhayujie.com
个人邮箱:[email protected]
展开
-
POJ-2488 国际象棋马的走法 (深度优先搜索和回溯)
#include #define MAX 27void dfs(int i, int j);int dx[8] = {-1, 1, -2, 2, -2, 2, -1, 1};int dy[8] = {-2, -2, -1, -1, 1, 1, 2, 2};int marked[MAX][MAX]; //标记int pathx[MAX];int pathy[MAX];int f原创 2017-07-03 22:16:50 · 1365 阅读 · 0 评论 -
PAT-1056 Mice and Rice (分组决胜问题)
1056. Mice and RiceMice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of ea原创 2017-09-05 12:37:34 · 416 阅读 · 0 评论 -
PAT-1079 Total Sales of Supply Chain (树的遍历)
1079. Total Sales of SupplyA supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting f原创 2017-09-01 16:20:45 · 283 阅读 · 0 评论 -
PAT-1078 Hashing (散列表 二次探测法)
1078. HashingThe 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原创 2017-08-30 23:02:55 · 759 阅读 · 0 评论 -
PAT-1134 Vertex Cover (图的建立 + set容器)
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e原创 2017-09-18 09:53:57 · 1016 阅读 · 0 评论 -
PAT-1135 Is It A Red-Black Tree(二叉查找树的创建和遍历)
There is a kind of balanced binary search tree namedred-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The root is black.(3)原创 2017-10-02 16:58:57 · 360 阅读 · 0 评论 -
PAT-1064 Complete Binary Search Tree(完全二叉树)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The right原创 2017-11-05 16:56:04 · 266 阅读 · 0 评论 -
PAT-1080 Graduate Admission (结构体排序)
1080. Graduate AdmissionIt is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could writ原创 2017-09-02 15:38:11 · 305 阅读 · 0 评论 -
PAT-1018 Public Bike Management(dijkstra + dfs)
1018. Public Bike Management (30)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world.原创 2017-08-25 21:33:31 · 325 阅读 · 0 评论 -
PAT 乙级-1025 链表反转
给定一个常数K以及一个单链表L,请编写程序将L中每K个结点反转。例如:给定L为1→2→3→4→5→6,K为3,则输出应该为3→2→1→6→5→4;如果K为4,则输出应该为4→3→2→1→5→6,即最后不到K个元素不反转。输入格式:每个输入包含1个测试用例。每个测试用例第1行给出第1个结点的地址、结点总个数正整数N(5)、以及正整数K(接下来有N行,每行格式为:A原创 2017-09-15 20:39:18 · 515 阅读 · 0 评论 -
POJ-1005
求房子过几年淹水的问题,确实是水题原创 2017-06-30 23:39:23 · 214 阅读 · 0 评论 -
PAT-1060 Are They Equal (科学计数法)
1060. Are They Equal If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*105 with simple chopping.原创 2017-09-12 11:19:20 · 284 阅读 · 0 评论 -
PAT-1063 Set Similarity (set集合)
1063. Set SimilarityGiven 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 i原创 2017-09-12 21:33:48 · 255 阅读 · 0 评论 -
PAT-1059 Prime Factors (素数因子)
1059. Prime FactorsGiven any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *…*pm^km.Input Specification:Each原创 2017-09-08 22:50:38 · 341 阅读 · 0 评论 -
PAT-1058 A+B in Hogwarts (进制转换)
1058. A+B in HogwartsIf 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 Gall原创 2017-09-08 21:02:10 · 257 阅读 · 0 评论 -
PAT-1057 Stack (树状数组 + 二分查找)
1057. StackStack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto t原创 2017-09-08 16:16:39 · 535 阅读 · 0 评论 -
PAT-1133 Splitting A Linked List(链表分解)
Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting原创 2017-09-17 21:52:17 · 534 阅读 · 0 评论 -
PAT-1132 Cut Integer (整数分割)
Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting原创 2017-09-17 20:49:37 · 391 阅读 · 0 评论