# train4 **Repository Path**: stopwithfailure/train4 ## Basic Information - **Project Name**: train4 - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-11-19 - **Last Updated**: 2021-11-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 2021年“蓝桥杯”研究生组选拔训练赛四题解 可以在下方评论区留言 ## A * 四舍五入:输入的两个数用double,计算结果加0.5再强制转化为int实现 * https://gitee.com/stopwithfailure/train4/blob/master/A.cpp ## B * 通过%==0找出约数,遍历求和,判断两个和是否互为对方 * https://gitee.com/stopwithfailure/train4/blob/master/B.cpp ## C * 排序简化判断的条件 * https://gitee.com/stopwithfailure/train4/blob/master/C.cpp ## D 1. 第一行输入牛数量和要覆盖的总时间,之后每行是每个牛的开始工作时间和结束时间 2. 创建一个含两个整数的结构体,将所有数据以开始时间降序,同时间按结束时间降序 3. 排序后,第一个牛必选,向后遍历到已覆盖的结束时间+1,找这个区间内结束时间最晚的,此时需要的牛数量+1,重复此过程 ![D](https://images.gitee.com/uploads/images/2021/1120/140214_b624a038_5034344.jpeg "屏幕截图 2021-11-20 133903.jpg") * 注意:第一个牛开始时间>1时无解;遍历某一区间结束时,别漏了下一区间的第一个值,使用i--解决此问题时,要防止死循环 * https://gitee.com/stopwithfailure/train4/blob/master/D.cpp * 可以参考其他回答 https://blog.csdn.net/jhgkjhg_ugtdk77/article/details/46127581 ## E * 从两边一直比到中间,有不一样的中断跳出改变标记 * https://gitee.com/stopwithfailure/train4/blob/master/E.cpp ## F 1. 用函数计算牌的分数 2. 将2-A转化为2-14,存入数组,排序后方便比较 3. 将不同类型加不同的基数,如同花顺90000000,四条80000000等。再将次大的值放入低位中,保证比较时他们的优先级。如:8C 8D 2H 3S 4H中,一对加基数20000000,最终计算结果20000000+4\*400+3\*20+2=20001662 4. 比较两副牌的计算结果 * https://gitee.com/stopwithfailure/train4/blob/master/F.cpp ## G、H * F题的简化版,可以用类似的方法 * https://gitee.com/stopwithfailure/train4/blob/master/G.cpp * https://gitee.com/stopwithfailure/train4/blob/master/H.cpp ## I 1. 判断是否结束:是否达到11分,分差是否>1 2. 判断谁发球:总分20之前,每人两次,%4;20分之后,一人一次,%2 * https://gitee.com/stopwithfailure/train4/blob/master/I.cpp ## J 1. 字符串读入,转化存入整数数组,右对齐 2. 循环两遍,计算每一位,处理借位 3. 从第一个不是0的数开始输出 * https://gitee.com/stopwithfailure/train4/blob/master/J.cpp