
练习--PAT
jackson_j
求大佬
展开
-
PAT--1025 PAT Ranking
#include <bits/stdc++.h>using namespace std;struct Student{ char id[15]; int local_rank; int local_number; int score;}s[30010];bool cmp(Student a, Student b){ if(a.sc...原创 2019-03-23 16:49:07 · 172 阅读 · 0 评论 -
PAT--1001 A+B Format (20 分)
Calculatea+band output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:Each input ...原创 2019-08-10 20:24:47 · 138 阅读 · 0 评论 -
PAT--1076 Forwards on Weibo (30 分)
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a ...原创 2019-08-24 17:13:27 · 108 阅读 · 0 评论 -
PAT--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 l...原创 2019-08-24 22:51:12 · 117 阅读 · 0 评论 -
PAT--1059 Prime Factors (25 分)
Given any positive integerN, you are supposed to find all of its prime factors, and write them in the formatN=p1k1×p2k2×⋯×pmkm.Input Specification:Each input file co...原创 2019-08-20 23:32:31 · 106 阅读 · 0 评论 -
PAT--1060 Are They Equal (25 分)
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as0.123×105with simple chopping. Now given the number of signif...原创 2019-08-20 23:53:36 · 106 阅读 · 0 评论 -
PAT--1034 Head of a Gang (30 分)
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a relation is defined to be t...原创 2019-08-23 12:37:11 · 118 阅读 · 0 评论 -
PAT--1032 Sharing (25 分)
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...原创 2019-08-22 23:13:27 · 102 阅读 · 0 评论 -
PAT--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 integerkeyand aNextpointer to the next structure. Now give...原创 2019-08-22 23:40:50 · 113 阅读 · 0 评论 -
PAT--1043 Is It a Binary Search Tree (25 分)
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 su...原创 2019-08-23 11:44:59 · 106 阅读 · 0 评论 -
PAT--1002 A+B for Polynomials (25 分)
This time, you are supposed to findA+BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2019-08-27 00:22:36 · 135 阅读 · 0 评论 -
PAT--1007 Maximum Subsequence Sum (25 分)
Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequen...原创 2019-08-27 23:39:03 · 105 阅读 · 0 评论 -
PAT--1009 Product of Polynomials (25 分)
This time, you are supposed to findA×BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2019-08-29 00:18:32 · 124 阅读 · 0 评论 -
PAT--1013 Battle Over Cities (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...原创 2019-08-29 23:38:56 · 149 阅读 · 0 评论 -
PAT--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. One may rent a bike at any station and return it to any other stations in the ...原创 2019-08-31 22:41:59 · 118 阅读 · 0 评论 -
PAT--1021 Deepest Root (25 分)
A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root ...原创 2019-09-01 11:21:38 · 125 阅读 · 0 评论 -
PAT--1030 Travel Plan (30 分)
A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b...原创 2019-09-01 12:53:10 · 115 阅读 · 0 评论 -
PAT--1086 Tree Traversals Again (25 分)
1086Tree Traversals Again(25分)An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered ...原创 2019-09-01 15:10:06 · 130 阅读 · 0 评论 -
PAT--1054 The Dominant Color (20 分)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the d...原创 2019-08-10 19:48:59 · 119 阅读 · 0 评论 -
PAT--1005 Spell It Right (20 分)
Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Eac...原创 2019-08-19 23:24:34 · 123 阅读 · 0 评论 -
PAT--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.Input Specification:Each input file contains one test case. Each case starts...原创 2019-08-18 23:36:54 · 166 阅读 · 0 评论 -
PAT--全排列
#include <bits/stdc++.h>using namespace std;const int maxn =11;//p为当前排列,hashTable记录整数x是否已经在p中int n,p[maxn],hashTable[maxn]={false};//当前处理排列的低index号位void generateP(int index){ if(ind...原创 2019-03-23 18:02:48 · 279 阅读 · 0 评论 -
PAT--1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are forRed, the middle 2 dig...原创 2019-08-04 21:34:12 · 74 阅读 · 0 评论 -
PAT--1064 Complete Binary Search Tree (30 分)
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 su...原创 2019-08-05 01:04:00 · 116 阅读 · 0 评论 -
PAT--1083 List Grades (25 分)
Given a list ofNstudent records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades ...原创 2019-08-05 15:31:20 · 144 阅读 · 0 评论 -
PAT--1092 To Buy or Not to Buy (20 分)
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sel...原创 2019-08-05 17:42:23 · 130 阅读 · 0 评论 -
PAT--1099 Build A Binary Search Tree (30 分)
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 su...原创 2019-08-05 19:00:58 · 111 阅读 · 0 评论 -
PAT--1102 Invert a Binary Tree (25 分)
The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off.Now it's your turn to...原创 2019-08-05 20:26:19 · 106 阅读 · 0 评论 -
PAT--1113 Integer Set Partition (25 分)
Given a set ofN(>1) positive integers, you are supposed to partition them into two disjoint setsA1andA2ofn1andn2numbers, respectively. LetS1andS2denote the sums of al...原创 2019-08-05 20:56:46 · 109 阅读 · 0 评论 -
PAT--1120 Friend Numbers (20 分)
Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their ...原创 2019-08-05 21:08:31 · 158 阅读 · 0 评论 -
PAT--1094 The Largest Generation
A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input ...原创 2019-08-05 22:23:57 · 118 阅读 · 0 评论 -
PAT--1006 Sign In and Sign Out (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...原创 2019-08-05 22:34:00 · 145 阅读 · 0 评论 -
PAT--1050 String Subtraction (20 分)
Given two stringsS1andS2,S=S1−S2is defined to be the remaining string after taking all the characters inS2fromS1. Your task is simply to calculateS1−S2for any given s...原创 2019-08-08 21:35:11 · 168 阅读 · 0 评论 -
PAT--1020 Tree Traversals (25 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor...原创 2019-08-06 20:09:59 · 145 阅读 · 0 评论 -
PAT--1051 Pop Sequence (25 分)
Given a stack which can keepMnumbers at most. PushNnumbers in the order of 1, 2, 3, ...,Nand pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of t...原创 2019-08-06 20:45:01 · 226 阅读 · 0 评论 -
PAT--1036 Boys vs Girls (25 分)
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one t...原创 2019-08-06 21:12:12 · 150 阅读 · 0 评论 -
PAT--1041 Be Unique (20 分)
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,104]. The first one who bets o...原创 2019-08-06 21:37:24 · 116 阅读 · 0 评论 -
PAT--1012 The Best Rank (25 分)
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE- Eng...原创 2019-09-02 16:18:11 · 135 阅读 · 0 评论