![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PTA
文章平均质量分 75
玛莱之盾
这个作者很懒,什么都没留下…
展开
-
1090 Highest Price in Supply Chain (25 分)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys products from one’s supplier in a price P an原创 2021-09-16 18:08:07 · 144 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25 分)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys products from one’s supplier in a price P an原创 2021-09-16 18:07:10 · 85 阅读 · 0 评论 -
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 prove that YOU CAN invert a binary tree!Input Specificati原创 2021-09-16 18:06:16 · 65 阅读 · 0 评论 -
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 corresponding binary tree.Input Specification:Each input原创 2021-09-16 18:05:39 · 65 阅读 · 0 评论 -
1086 Tree 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 from 1 to 6) is traversed, the stack operations are: push(1); push(2); push(3); pop(); pop(原创 2021-09-16 18:05:01 · 73 阅读 · 0 评论 -
1091 Acute Stroke (30 分)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core.Input Specificat原创 2021-09-14 16:39:44 · 75 阅读 · 0 评论 -
1103 Integer Factorization (30 分)
The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P factorization of N for any positive integers N, K and P.Input Specification:Each input fi原创 2021-09-14 16:39:09 · 67 阅读 · 0 评论 -
1056 Mice and Rice (25 分)
Mice 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 each mouse is to eat as much rice as possible in order to become a FatMouse.First the pl原创 2021-09-14 16:37:57 · 140 阅读 · 0 评论 -
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原创 2021-09-14 16:37:02 · 94 阅读 · 0 评论 -
1071 Speech Patterns (25 分)
People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while others may prefer “the cops”. Analyzing such patterns can help to narrow down a speaker’s identity, which is useful when validating, for exampl原创 2021-09-14 16:35:49 · 79 阅读 · 0 评论 -
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 dominant color. A strictly dominant color takes more than原创 2021-09-14 16:34:59 · 100 阅读 · 0 评论 -
1100 Mars Numbers (20 分)
People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, respectively.For the next higher digit, Mars people name原创 2021-09-14 16:34:04 · 71 阅读 · 0 评论 -
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 as 0.123×10510^5105 with simple chopping. Now given the number of significant digits on a machine and two float numbers, you原创 2021-09-14 08:16:22 · 62 阅读 · 0 评论 -
1063 Set Similarity (25 分)
Given two sets of integers, the similarity of the sets is defined to beNc/Nt×100N_c/N_t×100Nc/Nt×100%, whereNcN_cNc is the number of distinct common numbers shared by the two sets, and NtN_tNt is the total number of distinct numbers in the two set原创 2021-09-13 23:16:57 · 69 阅读 · 0 评论 -
1047 Student List for Course (25 分)
Zhejiang University has 40,000 students and provides 2,500 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原创 2021-09-13 23:16:04 · 89 阅读 · 0 评论 -
1039 Course List for Student (25 分)
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query.Input Specification:Each input file contai原创 2021-09-13 23:15:26 · 63 阅读 · 0 评论 -
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 fil原创 2021-09-13 23:14:16 · 86 阅读 · 0 评论 -
1104 Sum of Number Segments (20 分)
Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4)原创 2021-09-13 23:13:30 · 86 阅读 · 0 评论 -
1101 Quick Sort (25 分)
There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its left and those larger than the pivot to its right. Given N原创 2021-09-13 23:10:47 · 69 阅读 · 0 评论 -
1093 Count PAT‘s (25 分)
The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now given any string, you are supposed to tell the number of原创 2021-09-13 22:53:55 · 73 阅读 · 0 评论 -
1029 Median (25 分)
Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequences is defined to be the me原创 2021-09-13 22:51:16 · 2138 阅读 · 0 评论 -
1089 Insert or Merge (25 分)
According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, an原创 2021-09-13 22:50:26 · 56 阅读 · 0 评论 -
1044 Shopping in Mars (25 分)
Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$$). When making the payment, the chain can be cut at any position for only once and some of the diamonds are taken off th原创 2021-09-13 22:49:01 · 2221 阅读 · 0 评论 -
1085 Perfect Sequence (25 分)
Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×pM≤m×pM≤m×p whereMMMand mmm are the maximum and minimum numbers in the sequence, respectively.Now given a sequence and a param原创 2021-09-11 15:08:11 · 68 阅读 · 0 评论 -
1067 Sort with Swap(0, i) (25 分)
Given any permutation of the numbers {0, 1, 2,…, N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may apply the swap operations in the following原创 2021-09-11 15:06:00 · 61 阅读 · 0 评论 -
10050 String Subtraction (20 分)
Given two strings S1S_1S1and S2S_2S2, S=S1−S2S=S_1-S_2S=S1−S2is defined to be the remaining string after taking all the characters in S2S_2S2 from S1S_1S1. Your task is simply to calculate for S1−S2S_1-S_2S1−S2 any given strings. However, it mig原创 2021-09-11 15:04:42 · 60 阅读 · 0 评论 -
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,10410^4104]. The first one who bets on a unique number wins. For example, if there are 7原创 2021-09-11 15:03:17 · 70 阅读 · 0 评论 -
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 sell the strings in whole pieces. Hence Eva must check whet原创 2021-09-11 15:02:13 · 52 阅读 · 0 评论 -
1084 Broken Keyboard (20 分)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to type, and the string that you actually type out, please原创 2021-09-11 15:01:11 · 63 阅读 · 0 评论 -
1089 Insert or Merge (25 分)
1089 Insert or Merge (25 分)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belong原创 2021-09-11 14:59:05 · 86 阅读 · 0 评论 -
1083 List Grades (25 分)
1083 List Grades (25 分)Given a list of N student 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 are in a given interval.Input S原创 2021-09-11 14:55:19 · 158 阅读 · 0 评论 -
1055 The World‘s Richest (25 分)
Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain range of ages. That is, given the net wor原创 2021-09-11 14:54:18 · 213 阅读 · 0 评论 -
1028 List Sorting (25 分)
1028 List Sorting (25 分)Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two integers N (≤10510^5105) and C,原创 2021-09-11 14:50:58 · 75 阅读 · 0 评论 -
数据结构---并查集
在培训的时候讲到过这个东西,当时是在讲迪杰斯特拉算法的时候,没做重点,没想到校赛模拟的时候又考到了,于是花了一点时间研究了一下。并查集是一种树状结构,用来判断连通分支数很好用(离散刚学过),所谓的连通分支数简单来说就是就是给你一些点,和各个点的连通情况,让你判断有谁和谁连在一起,或者是这个连通分支上有多少个点,又或者一共有多少个连通分支。并查集还用来路径压缩,这里就不放图了,好多大佬讲的很好我也是看了才明白的。可以简理解为找老大,先初始化化每个人是自己的老大,然后通过join操作,使得树状的一级一级的关原创 2021-02-01 20:54:54 · 189 阅读 · 0 评论 -
递归系列---1.青蛙跳台阶 (10分)
递归系列—1.青蛙跳台阶 (10分)在PTA上刷题,遇到这个问题,高三的时候听数学老师讲过,当时不知道什么是递归,现在明白了,觉得有点意思。题意:一只青蛙一次可以跳上 1 级台阶,也可以跳上2 级。求该青蛙跳上一个n 级的台阶总共有多少种跳法。输入格式:首先输入数字n,代表接下来有n组输入,50>=n>=0,然后每行一个数字,代表台阶数,数字为小于60的整数输出格式:对每一组输入,输出青蛙的跳法。输入样例:3123输出样例:123我对于递归的理解是,大的问题,可原创 2021-01-25 15:42:46 · 1359 阅读 · 1 评论 -
前缀和---最大子串和问题
#include <stdio.h>#define maxn 10000int num[maxn],pre[maxn];int flag=-1;void mssum(int n,int a[]){ int i,j,max=-1,temp1,temp2; for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(i==0) {原创 2021-01-25 21:34:44 · 351 阅读 · 0 评论