摘要:
1052. Linked List Sorting (25)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and aNextpointer to the next structure. Now given a linked list, you are supposed to sort the structures according to th 阅读全文
随笔分类 - PAT
PAT 解题报告 1051. Pop Sequence (25)
2014-02-28 20:27 by Loull, 1215 阅读, 收藏, 编辑
摘要:
1051. Pop Sequence (25)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we can obtain 1, 2, 3, 4, 5, 6, 阅读全文
PAT 解题报告 1050. String Subtraction (20)
2014-02-28 20:00 by Loull, 416 阅读, 收藏, 编辑
摘要:
1050. String Subtraction (20)Given two strings S1and S2, S = S1- S2is defined to be the remaining string after taking all the characters in S2from S1. Your task is simply to calculate S1- S2for any given strings. However, it might not be that simple to do itfast.Input Specification:Each input file c 阅读全文
PAT 解题报告 1049. Counting Ones (30)
2014-02-28 19:37 by Loull, 436 阅读, 收藏, 编辑
摘要:
1049. Counting Ones (30)The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's in 1, 10, 11, and 12.Input Specification:Each input file contains one 阅读全文
PAT 解题报告 1048. Find Coins (25)
2014-02-28 19:30 by Loull, 356 阅读, 收藏, 编辑
摘要:
1048. Find Coins (25)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for each bill, she could only 阅读全文
PAT 解题报告 1047. Student List for Course (25)
2014-02-28 19:22 by Loull, 360 阅读, 收藏, 编辑
摘要:
1047. Student List for Course (25)Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input Specification:Each input file contains one test case. For each case, th 阅读全文
PAT 解题报告 1013. Battle Over Cities (25)
2014-02-27 15:59 by Loull, 2130 阅读, 收藏, 编辑
摘要:
1013. Battle Over Cities (25)t 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 need to repair any other highways to keep the rest of the cities connected. 阅读全文
PAT 解题报告 1010. Radix (25)
2014-02-27 15:19 by Loull, 3670 阅读, 收藏, 编辑
摘要:
1010. Radix (25)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 integers N1 and N2, your task is to find the radix of one number while that of 阅读全文
PAT 解题报告 1009. Product of Polynomials (25)
2014-02-27 15:11 by Loull, 548 阅读, 收藏, 编辑
摘要:
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 information of a polynomial: K N1 aN1N2 aN2... NK aNK, where K is the number of nonzero terms in the polynomial 阅读全文
PAT 解题报告 1007. Maximum Subsequence Sum (25)
2014-02-27 15:04 by Loull, 965 阅读, 收藏, 编辑
摘要:
Given a sequence of K integers { N1, N2, ..., NK}. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj} where 1 mx) { mx = sum; s = i;t = j; } } } printf("%d %d %d", mx,n[s], n[t]);思路2、扫描经典DP问题, 基于这样一个事实:保存一个最大字段和以及一个当前子段和, 如果当前字段和大于当前... 阅读全文
PAT 解题报告 1003. Emergency (25)
2014-02-27 14:31 by Loull, 3966 阅读, 收藏, 编辑
摘要:
1003. Emergency (25)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there 阅读全文
PAT 解题报告 1004. Counting Leaves (30)
2014-02-27 14:26 by Loull, 785 阅读, 收藏, 编辑
摘要:
1004. Counting Leaves (30)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case. Each case starts with a line containing 0 #include #include #include #include using namespace std;#define MX 阅读全文