PAT
迟语ccc
这个作者很懒,什么都没留下…
展开
-
【PAT】A1031 Hello World for U (20分)
思路:对于U形,我们把左边、底边、右边设为n1,n2,n3。按照题目所给的规律,即n1 = n3 = 小于n2的最大的数,且n1 + n2 + n3 = N + 2(因为两个角落有重叠)在草稿纸上画了几个特殊情况(N=5画到了N=10)可以发现都是先增加底边的字符数,直到n1 = n2 = n3后才开始增加侧边的字符数可以算出n1 = n3 = (N + 2)/ 3,向下取整n2 ...原创 2020-03-24 15:41:54 · 131 阅读 · 0 评论 -
【PAT】A1009
//思路://先获得第一个多项式的系数,然后在输入第二个系数时循环与第一个多项式的系数相乘,并将结果加到对应指数的系数上//最后得到要输出的所有非零系数的项 //没必要开两个数组 #include <cstdio>struct Poly{ int exp;//指数 double cof;//系数 }poly[1001];double ans[2001];int m...原创 2020-03-22 18:33:34 · 137 阅读 · 0 评论 -
【PAT】1042 Shuffling Machine (20分)
思路:大概就是要对54张牌按照给的顺序进行打乱,把第i张牌放到位置j上,这个操作重复k次。因为题目中给出的操作已经明确了每个位置上的牌在操作后的位置,所以可以设两个数组start和end,分别存操作前、操作后的牌的位置,在一次操作结束后再用end数组更新start数组的值。用order数组存牌号(1-54),用mp数组存花色(SHCDJ五个花色),牌号x的花色可以计算的到,是mp[(x...原创 2020-03-21 14:38:40 · 101 阅读 · 0 评论 -
A1012
#include <iostream> #include <cstdio>#include <cmath>#include <algorithm>using namespace std;struct Student{ int id; int grade[4];}student[2010];char course[4]={'A',...原创 2020-01-29 15:55:39 · 246 阅读 · 0 评论 -
PAT 1001 A+B Format
1001 A+B Format (20)(20 分)Calculate a + b and 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).Inp...原创 2018-07-23 21:58:03 · 210 阅读 · 0 评论