PAT Grade A-Record

  1. A+B Format : d/1000%1000 is written as d%1000%1000
  2. A+B for Polynomials :: The use of map, the third parameter in the map declaration is the structure cmp, which is used for the sorting of the map itself. The map uses the same as the array map[i] =1; the iterator is reviewed here For the loop of, use auto directly, for MAP, vector, etc., begin and .end are used to loop through
  3. Emergency:DFS~
  4. Counting Leaves : Count nodes that have no children, just use the function to calculate recursively
  5. Spell It Right : Simple simulation
  6. Sign In and Sign Out : simple, string can be directly compared, sort sorts the structure, write a cmp function
  7. Maximum Subsequence Sum : DP, the sum of the largest subsequence
  8. Elevator : Simple simulation
  9. Product of Polynomials : Similar to 2, MAP is used in order
  10. Radix
  11. World Cup Betting : Simple simulation
  12. The Best Rank : Sorting is very cumbersome, and there are a lot of repeated codes. The same score in this question is ranked, such as 1,1,3,4 instead of 1,1,2,3
  13. Battle Over Cities : Calculate the number of connected graphs and subtract 1
  14. Waiting in Line : The simulation is about to throw up, so difficult~~~
  15. Reversible Primes : relatively simple, there is a pit, to determine the prime number to add if (x<=1) to return to 0 conditions (to_string and atoi are used for direct conversion between string and int)
  16. Phone Bills : cumbersome
  17. Queueing at Bank : Simulation is similar to 14, but difficult~~~
  18. Public Bike Management : DFS, there is a pit, such as: 5-0-10 this example, the perfect situation is 5, the correct way should be 5, enter 5 instead of no need to leave;
  19. General Palindromic Number : base conversion, judging whether it is a palindrome number, simple, but there is a pit, you can not use string to save, for example: if the base is 15, then the number N may appear 10-14, string to judge It can only be 1-9, so here is an array to deal with
  20. Tree Traversals : give post sequence and middle sequence, output layer sequence
  21. Deepest Root : The output is the deepest root, and there is a pit-----When recording the result (the first time I wrote it is different from this time), I got stuck in TM for a long time.
  22. Digital Library : Enter! !
  23. Have Fun with Number : Addition or multiplication of large integers (here *2), the meaning of the question is somewhat problematic, here is to judge whether the number of times each number appears is equal, not whether the number appears
  24. Palindromic Number : Add large integers to determine whether a number is symmetrical, and the array should be larger
  25. PAT Ranking : the ranking of the structure
  26. Table tennis : EMMM, difficult
  27. Colors in Mars : similar to hexadecimal conversion, simple, pay attention to the special case of filling 0
  28. List Sorting : structure sorting, simple
  29. Median : To find the median, you can use a simple method directly~~
  30. Travel Plan : pure DFS record path
  31. Hello World for U : Give a string, no spaces, and simulate output. According to the formula, n1 and n2 are the key
  32. Sharing : Find the same suffix of the string, it is more convenient to use set
  33. To Fill or Not to Fill : Greedy algorithm
  34. Head of a Gang : The use of map instead of two-dimensional array, DFS, the memory of the second write exceeds the limit
  35. Password : Simple simulation
  36. Boys vs Girls : Simple simulation
  37. Magic Coupon : Simulation, the code written for the first time is long, and the code written for the second review is relatively short, so skin-friendly~~
  38. Recover the Smallest Number : It is still relatively simple, there is a special prefix 0 processing
  39. Course List for Student : Sort the map. You can’t use cin when outputting, otherwise the last test point will time out, just use scanf
  40. Longest Symmetric String:DP
  41. Be Unique : Simple simulation, map mapping
  42. Shuffling Machine : Simple simulation, swap positions

Guess you like

Origin blog.csdn.net/qq_43567222/article/details/112921547
Recommended