oj-----PAT 甲级
oj
PX-C
以学好IT技术为目的。
展开
-
1004 Counting Leaves (30)(30 分)
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contains one test case. Each case starts with a line...原创 2018-08-03 18:17:47 · 222 阅读 · 0 评论 -
1144 The Missing Number(20 分)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains one test case. For each case, the first line giv...原创 2018-08-21 17:48:42 · 251 阅读 · 0 评论 -
1147 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 (i...原创 2018-08-22 19:35:35 · 233 阅读 · 0 评论 -
1140 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 n...原创 2018-08-29 15:00:00 · 173 阅读 · 0 评论 -
1136 A Delayed Palindrome(20 分)
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0with 0≤ai<10 for all i and ak>0. Then N is palindromic if and only if ai=ak−i for ...原创 2018-09-04 09:49:34 · 192 阅读 · 0 评论 -
1141 PAT Ranking of Institutions(25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist. Input Specification: Each input file conta...原创 2018-08-29 21:47:31 · 153 阅读 · 0 评论 -
1143 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 ...原创 2018-09-02 10:13:51 · 386 阅读 · 0 评论 -
1138 Postorder Traversal(25 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...原创 2018-09-06 11:32:18 · 282 阅读 · 0 评论 -
1132 Cut Integer(20 分)
Cutting an integer means to cut a K digits lone 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...原创 2018-09-06 13:29:44 · 268 阅读 · 0 评论 -
1145 Hashing - Average Search Time(25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...原创 2018-08-24 13:52:27 · 229 阅读 · 0 评论 -
1142 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 adj...原创 2018-08-31 11:50:56 · 222 阅读 · 0 评论 -
1009 Product of Polynomials (25)(25 分)
This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2018-08-03 21:23:30 · 178 阅读 · 0 评论 -
1008 Elevator (20)(20 分)
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec...原创 2018-08-03 21:25:20 · 245 阅读 · 0 评论 -
1013 Battle Over Cities (25)(25 分)
It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee...原创 2018-08-05 16:04:01 · 264 阅读 · 0 评论 -
1011 World Cup Betting (20)(20 分)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Si...原创 2018-08-05 16:56:31 · 140 阅读 · 0 评论 -
1005 Spell It Right (20)(20 分)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. ...原创 2018-08-02 21:26:29 · 548 阅读 · 0 评论 -
1006 Sign In and Sign Out (25)(25 分)
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you...原创 2018-08-02 21:28:59 · 559 阅读 · 0 评论 -
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 <= i <= j <= K. The Maximum Subsequence is the continuo...原创 2018-08-02 21:45:26 · 342 阅读 · 0 评论 -
1015 Reversible Primes (20)
A reversible prime in 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 pr...原创 2018-08-12 15:12:09 · 221 阅读 · 0 评论 -
1133 Splitting A Linked List(25 分)
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...原创 2018-09-06 14:01:16 · 242 阅读 · 0 评论