PAT甲级
PAT (Advanced Level) Practice
Greylan
练习用。
展开
-
A1002
A+B for Polynomials(25分)单词:polynomials:多项式 coefficient:系数 exponent:指数 nonzero term:非零项 be accurate to 1 decimal place:精确到一位小数 decimal:小数;十进制的总结:设立数组m,长度为指数e最大值+1,下标与指数一一对应,存储对应的系数。 ...原创 2020-07-05 20:37:30 · 136 阅读 · 0 评论 -
A1006
Sign In and Sign Out(25分)单词:总结:代码:#include <cstdio>int main(){ return 0;}原创 2020-07-07 13:43:25 · 79 阅读 · 0 评论 -
A1009
Product of Polynomials(25分)单词:the product ofAandB:A和B的乘积总结:a[1001]:第一个多项式。无需存第二个多项式,可边输入边得出结果。 m[2001]:结果。x^1000 *x^1000 =x^2000,相乘指数可达2000,数组开到2001。 格式:double类型输入%lf,输出%f。格式控制%.1f,保留一位小数。代码 :#include<cstdio>int main(){ double ...原创 2020-07-05 21:36:17 · 336 阅读 · 0 评论 -
A1011
World Cup Betting(20分)单词:odds: 概率,投注赔率 The winner's odd would bethe product of the three odds times 65%: 赢家的赔率是(选择的)三个赔率的乘积再乘以65%总结:边输入边输出:一组数据(一行三个数)输入完毕, 立即输出三个数中最大的,并进行累乘。 max初值取0.65 或者 1.0需要再*0.65。代码:#include <cstdio> double Fi...原创 2020-07-06 22:25:48 · 106 阅读 · 0 评论 -
A1019
General Palindromic Number(20分)单词:palindromic number:回文数总结:代码:原创 2020-07-08 14:47:02 · 106 阅读 · 0 评论 -
A1027
Colors in Mars(20分)总结:进制转换,10进制→13进制,只有两位数直接输出即可,num/13为高位,num%13为低位。 输出转换使用char数组。 因为1直接计算两位结果,所以不需要补齐0。单纯一提,控制输出可以用%02d,表示输出2位,不足用0补齐。代码:#include <cstdio>char c[14]={"0123456789ABC"};int main(){ /*第一次用了数组存R/G/B 后发现无需数组存储 边输入边处理即可 ..原创 2020-07-08 15:48:37 · 159 阅读 · 0 评论 -
A1031
Hello World for U(20分)总结1:题目给明了n1+n2+n3=字符串长度+2,就说明了n1,n2,n3是有重叠的,画图会清晰很多。(一开始没注意按不重叠算,其余测试数据都通过,测试点5会出错。还是认真读题!) 记n1=n2=x(含底部一行的字符),已知2x+n2=N+2,n2>=x,结合画图U字,易得x取(N+2)/3。 不含底部的竖直部分为(N+2)/3-1,也是我的代码中定义的k的含义。不同的k和bot的定义会导致输出部分的条件判定不同,但大体上是一样的。 特例:.原创 2020-07-07 17:51:01 · 95 阅读 · 0 评论 -
A1036
Boys vs Girls(25分)总结:最低M分数初始化为101,最高F分数初始化为-1;因为分数范围[0,100],0和100可以取到。代码:#include <iostream>#include <cstring>using namespace std;int main(){ int n, grade, max=-1, min=101 ;//初始化 char gender; string name, id, maxname="Absent", .原创 2020-07-07 14:38:42 · 93 阅读 · 0 评论 -
A1042
Shuffling Machine(20分)单词:shuffling:洗牌 position:位置 the number at thei-th position isj, it means to move the card from positionito positionj: 第i个位置上是j,表示移动第i个位置上的数字→第j个位置。(即order[ i ] = j, 那么end[ j ]=start[ i ])。总结:利用char数组控制输出,char m...原创 2020-07-04 18:12:29 · 2198 阅读 · 0 评论 -
A1046
Shortest Distance(20分)总结:代码:#include<cstdio>const int MAXN = 100001;const int MAXM = 10001;int d[MAXN] ,dis[MAXN] ;int fin[MAXM];int min(int a, int b){ if(a>b) return b; else return a; }int main(){ int n; scanf("%d", &..原创 2020-07-05 15:43:42 · 99 阅读 · 0 评论 -
A1058
A+B in Hogwarts(20分)总结:简单的进制转化。类似B1037 g→s是17,s→p是29,进制转化不相同。代码:#include <cstdio>int main(){ int gp, sp, kp, ga, sa, ka; int g, s, k; scanf("%d.%d.%d", &gp, &sp, &kp); scanf("%d.%d.%d", &ga, &sa, &ka); k = kp .原创 2020-07-08 16:28:41 · 86 阅读 · 0 评论 -
A1061/B1014
Dating(20分)单词:case sensitive:大小写敏感总结:代码:原创 2020-08-08 18:19:39 · 113 阅读 · 0 评论 -
A1065
1065A+B and C (64bit)(20分)总结:A和B范围:[-2^63, 2^63],暂不考虑取到2^63,可使用long long型存储,范围为[-2^63, 2^63-1]。 [-2^63, 2^63-1]内两个数加法会产生溢出:A>0,B<0 或 A<0,B>0时,A、B异号,不会溢出。 A>0,B>0时,可能正溢出,sum范围[2, 2^64-2],其中[2^63, 2^64-2]部分溢出,实际结果为[2^63-2^64, 2^64...原创 2020-07-05 16:25:38 · 180 阅读 · 0 评论 -
A1073/B1024
Scientific Notation(20分)单词:scientific notation:科学计数法 notation:符号,记号 trailing:尾部的 the fractional portion:小数部分 the integer portion has exactly one digit, there is at least one digit in the fractional portion: 整数部分只有 1 位,小数部分至少有 1 位总结:代码:/...原创 2020-08-12 16:24:42 · 106 阅读 · 0 评论