PAT甲级1005水题飘过】的更多相关文章

题目分析:用一个字符串输入之后遍历每一位求和后,不断%10获取最后一位存储下来,逆序用对应的英文单词输出(注意输入为0的情况) #include<iostream> #include<string> using namespace std; ] = {"zero", "one", "two", "three", "four", "five", "six&…
题目分析: 将n转成对应大小的b进制数之后判断是否为回文串,是则Yes,否则No #include<iostream> using namespace std; ]; //存放从0开始b进制的每一位数 void run(int n, int b){ ; ){ k[cnt] = n % b; n /= b; cnt++; } ; ; i < cnt / ; i++){ ]){ flag = ; break; } } ) printf("Yes\n"); else pri…
题目分析:由于不存在相同的两个时间(24:00:00和00:00:00不会同时存在),则我们假设两个全局变量存放到达的最早的时间和达到的最晚的时间,设置最早的初值为“23:59:59”,设置最晚的初值为“00:00:00”,只要一个人到达的时间比最早的早则更新最早时间同时将id记录下来,最晚的情况也是同样的 #include<iostream> #include<string> using namespace std; int main(){ int n; while(scanf(…
题目分析:简单的多项式的模拟乘法,你可以假设未知数为x,exp为x的指数,coe为x的系数,则很容易就把答案推算出来,注意答案是从指数的高往低输出,同时要注意的是这是多项式的乘法,虽然指数的范围只有0~1000,但是乘法结果的指数范围为0~2000,注意数组定义的范围,开小了会产生段错误(下标越界,访问了不该访问的内存) #include<iostream> using namespace std; struct Node{ int exp; //指数 double coe; //系数 }k[…
题目分析:对于输入的数据分三条,选出每条中最大值记录下来,按照题目要求算出最大可能的获利即可 #include<iostream> using namespace std; ]; //k数组存放每次的三个倍率 ]; //存放三次选择的下标 ] = {'W', 'T', 'L'}; //存放输出的三个字符 int main(){ ], &k[], &k[]) != EOF){ double out = 1.0; double ma = 0.0; ; ; i < ; i++)…
题目分析:上去下来到达的时间和数量 #include<iostream> using namespace std; ]; int main(){ int n; while(scanf("%d", &n) != EOF){ ; ; ans += n*; ; i <= n; i++){ scanf("%d", &k[i]); if(k[i] > floor){ ans += (k[i] - floor) * ; floor = k…
#include<iostream> #include<string.h> using namespace std; ]; int main(){ int n1, n2; while(scanf("%d", &n1) != EOF){ memset(a, , sizeof(a)); ; i <= n1; i++){ int x; double y; scanf("%d%lf", &x, &y); a[x] +=…
#include<iostream> using namespace std; int main(){ int a, b; while(scanf("%d%d", &a, &b) != EOF){ int c = a + b; ) printf("0\n"); else{ ){ printf("-"); c = -c; } ]; ; ){ ; c /= ; k[cnt++] = x; } ; i >= ; i--…
刷题链接:https://www.patest.cn/contests/pat-a-practise 1001 #include <iostream> #include <stdio.h> using namespace std; ]; int main() { int a,b,sum,index; while(scanf("%d%d",&a,&b)!=EOF){ sum=a+b; ){ printf("-"); sum=-s…
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line…
Dijkstra PAT (Advanced Level) Practice Dijkstra 相关题 目录 <算法笔记>重点摘要 1003 Emergency (25) <算法笔记> 10.4.1 Dijkstra 重点摘要 对任意给出的图 G(V,E) 和 起点 S,终点 T,求 S 到 T 的最短路径 1. 简介 解决单源最短路问题 只能处理所有边权均非负的情况 若出现负数,最好使用 SPFA 算法 2. 邻接矩阵 const int MAXV = 1000; const i…
字符串处理题 目录 <算法笔记> 重点摘要 1001 A+B Format (20) 1005 Spell It Right (20) 1108 Finding Average (20) 1132 Cut Integer (20) 1140 Look-and-say Sequence <算法笔记> 3.6 字符串处理 重点摘要 注意分析输入输出格式 注意细节和边界情况 1001 A+B Format (20) #include<iostream> using names…
散列 PAT (Advanced Level) Practice 散列题 目录 <算法笔记> 重点摘要 1002 A+B for Polynomials (25) 1009 Product of Polynomials (25) 1084 Broken Keyboard (20) 1092 To Buy or Not to Buy (20) 1116 Come on! Let's C (20) 1121 Damn Single (25) <算法笔记> 4.2 散列 重点摘要 1.…
二叉树 PAT (Advanced Level) Practice 二叉树 相关题 目录 <算法笔记> 重点摘要 1020 Tree Traversals (25) 1086 Tree Traversals Again (25) 1102 Invert a Binary Tree (25) 1119 Pre- and Post-order Traversals (30) 1127 ZigZagging on a Tree (30) 1138 Postorder Traversal (25) 1…
二叉查找树 PAT (Advanced Level) Practice 二叉查找树 相关题 目录 <算法笔记> 重点摘要 1099 Build A Binary Search Tree (30) 1115 Counting Nodes in a BST (30) 1143 Lowest Common Ancestor (30) <算法笔记> 9.4 二叉查找树 重点摘要 二叉查找树静态实现 ⭐ (1) 定义 struct Node{ typename data; int level…
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one l…
题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 = 10000 所以 sum 用int 保存就好了 再把 sum 的每一位 用 英文输出 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include <cstdlib> #incl…
图 PAT (Advanced Level) Practice 用到图的存储方式,但没有用到图的算法的题目 目录 1122 Hamiltonian Cycle (25) 1126 Eulerian Path (25) 1134 Vertex Cover (25) 1142 Maximal Clique (25) 1154 Vertex Coloring (25) 1122 Hamiltonian Cycle (25) 题目思路 用 n != queryV.size() 检查是否 query 覆盖…
https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336 Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file c…
树 目录 <算法笔记>重点摘要 1004 Counting Leaves (30) 1053 Path of Equal Weight (30) 1079 Total Sales of Supply Chain (25) 1090 Highest Price in Supply Chain (25) 1094 The Largest Generation (25) 1106 Lowest Price in Supply Chain (25) <算法笔记> 9.2 树的遍历 重点摘要…
堆 目录 <算法笔记>重点摘要 1147 Heaps (30) 1155 Heap Paths (30) <算法笔记> 9.7 堆 重点摘要 1. 定义 堆是完全二叉树,树中每个结点的值不小于(或不大于)其左右子结点的值,称之为大顶堆(或小顶堆) const int maxn = 100; int heap[maxn], n = 10; // heap 为堆,n 为元素个数 2. 向下调整 // 对 heap 数组在 [low,high] 范围进行向下调整 // 其中 low 为欲…
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; typedef struct node{ int data; node *lchild,*rchild; }tree; ]; tree *build(int l,int r){ if(l>r) return NULL; ,pos=; for(int i=l;i<=r;++i) if(a[i]<mn) mn=a[i],pos=i;…
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ]; ]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,m; cin>>n>>m; ;i<=m;++i){ int x,y; cin>>x>>y; v[x].insert(y);…
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (≤10 ​1…
PAT链表专题 关于PAT甲级的链表问题,主要内容 就是"建立链表" 所以第一步学会模拟链表,pat又不卡时间,这里用vector + 结构体,更简洁 模拟链表的普遍代码 const int maxn = 1e6+10; struct node{ int address; int next; char key; }nod[maxn]; int head1,n; vector<node> list1; cin>>head1>>n; for(int i=…
同上一篇博客: 贪心题目我已经刷了将近30道了,由于那几天考驾照就没写,以后有空的时候补过来吧,都在codeblock里 pat的题也刷了点,acwing 的题也刷了点,基本都攒下了.以后也会慢慢补过来的 这几天都在备战四级,上午司机下午算法,有点忙不过来就一直没写博客,今天打完比赛就想趁热写一下吧,正好昨天也做了22年夏的甲级考试 来说说pat甲级: 第一次做pat甲级考试真题感受,一共4道题须在3个小时内做完,我感觉这真的是时间很充裕了 同时四道题的难度可能也是逐级拉开的,通常甲级前两道题是…
准备每天刷两题PAT真题.(一句话题解) 1001 A+B Format  模拟输出,注意格式 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; string ans = ""; int main() { ; cin >> a >> b; c = a + b; ) {…
本文为PAT甲级分类汇编系列文章. 集合.散列.数学.算法,这几类的题目都比较少,放到一起讲. 题号 标题 分数 大意 类型 1063 Set Similarity 25 集合相似度 集合 1067 Sort with Swap(0, i) 25 通过与0号元素交换来排序 数学 1068 Find More Coins 30 子集和问题 算法 1070 Mooncake 25 背包问题 算法 1078 Hashing 25 散列 散列 1085 Perfect Sequence 25 符合约束的…
本文为PAT甲级分类汇编系列文章. 排序题,就是以排序算法为主的题.纯排序,用 std::sort 就能解决的那种,20分都算不上,只能放在乙级,甲级的排序题要么是排序的规则复杂,要么是排完序还要做点什么的. 在1051至1100中有6道: 题号 标题 分数 大意 时间 1055 The World's Richest 25 限定范围排序结果 500ms 1056 Mice and Rice 25 分组排序 200ms 1062 Talent and Virtue 25 一定规则的排序 400m…