1070 Mooncake (25 分)   Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now given the inventory amounts…
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, loading and being are store…
题目链接 https://www.patest.cn/contests/pat-b-practise/1085 思路 结构体排序 要注意几个点 它的加权总分 是 取其整数部分 也就是 要 向下取整 然后这个操作要在排序操作之前 不能在输出的时候 进行 不然最后一个测试点 过不了 因为 假如 有两个学校的分数 分别是 195.1 195.2 如果排序按照这个排 就是 195.1 < 195.2 就会按照 总分来排 但实际上 向下取整之后 都是195 所以应该按照 考生人数 或者是单位码来排的 还有…
题意: 输入两个正整数N和M(存疑M是否为整数,N<=1000,M<=500)表示月饼的种数和市场对于月饼的最大需求,接着输入N个正整数表示某种月饼的库存,再输入N个正数表示某种月饼库存全部出手的利润.输出最大利润. trick: 测试点2可能包含M不为整数的数据.(尽管题面说明M是正整数,可是根据从前PAT甲级题目的经验,有可能不是整数.....) AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.…
题目 Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the regions culture. Now given the inventory amounts and the prices of al…
1078 Hashing (25 分)   The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be ( where TSize is the maximum size of the ha…
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 sequen…
题目描述 世博会志愿者的选拔工作正在 A 市如火如荼的进行.为了选拔最合适的人才,A市对所有报名的选手进行了笔试,笔试分数达到面试分数线的选手方可进入面试. 面试分数线根据计划录取人数的150%划定,即如果计划录取m名志愿者,则面试分数线为排名第m×150%(向下取整)名的选手的分数,而最终进入面试的选手 为笔试成绩不低于面试分数线的所有选手.现在就请你编写程序划定面试分数线,并输出所有进入面试的选手的报名号和笔试成绩. 输入输出格式 输入格式: 第一行,两个整数 n,m(5≤n≤5000,3≤…
题目链接 https://www.patest.cn/contests/pat-a-practise/1028 思路 就按照 它的三种方式 设计 comp 函数 然后快排就好了 但是 如果用 c++ 中的 string 保存名字的话 就会超时 所以 用 c 里面的 char *s 就可以过 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include <cstdlib> #incl…
题意:给出很多商品,每个商品有价值和出售期限,只能在期限内出售才能获取利润,每一个单位时间只能出售一种商品,问最多能获得多少利润. 只需要按照优先价值大的,其次时间长的排序所有物品,然后贪心选择,从它可以选的时间开始往前遍历,如果某个时间点没有出售过商品,那就放在那个时间出售,就这样就行. #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct work{…