
PAT
Decmxj1229
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PAT B1001 害死人不偿命的(3n+1)猜想
简单的模拟,while n=1 位临界条件#include <iostream>#include <algorithm>#include <string>int main(){ int step=0,n; scanf("%d",&n); while(n!=1){ if(n%2==0) {...原创 2019-03-08 20:59:35 · 207 阅读 · 0 评论 -
PAT B1027 打印沙漏
题目code#include <iostream>#include <algorithm>#include <string>#include <cmath>using namespace std;int main(){ int n,bottom; // n为总字节数 char a; scanf("%d %c"...原创 2019-03-12 11:51:09 · 177 阅读 · 0 评论 -
PAT A1031 Hello World for U
题目code#include <iostream>#include <algorithm>#include <cstring>#include <cmath>using namespace std;int main(){ char str[100],ans[40][40]; scanf("%s",str); i...原创 2019-03-12 15:03:06 · 152 阅读 · 0 评论 -
PAT A1060 Are They Equal
#include <string>#include <iostream>using namespace std;int N;void getK(string &num,int &n){ while(num[0] == '0') num.erase(num.begin()); if(num.length() == 0){ //处理0 num...原创 2019-03-17 13:49:39 · 166 阅读 · 0 评论 -
START 深度优先遍历DFS_栈
#include <cstdio>const int maxn=30;int n,V,maxValue=0;int w[maxn],c[maxn]; //w[i]为每件物品的质量,c 为每件物品的价值void DFS(int index,int sumW,int sumC){//递归可以很好的实现深度优先遍历 if(index==n){//死胡同 已经完成了对于n件物品的...原创 2019-03-21 11:06:00 · 231 阅读 · 0 评论 -
PAT A1032 Sharing
题目code#include <cstdio>#include <string>const int maxn=100010;struct Node{//定义静态链表 char data; int next; bool flag;//随题目改变}node[maxn];int main(){ int s1,s2,n; sc...原创 2019-03-18 20:56:03 · 140 阅读 · 0 评论 -
PAT A1020 Tree Traversals
题目简单来说就是 知后序遍历和中序遍历求层次遍历思路先根据后序遍历和中序遍历建出二叉树BFS求层次遍历code# include <cstdio># include <queue># include <algorithm># include <cstring>using namespace std;struct node{...原创 2019-03-25 21:10:57 · 224 阅读 · 0 评论 -
PAT A1102 Invert a Binary Tree
题目code# include <cstdio># include <queue># include <stack># include <algorithm># include <cstring>using namespace std;const int maxn=110;struct node{ int lc...原创 2019-03-29 21:38:49 · 225 阅读 · 0 评论 -
PAT A1086 Tree Traversals Again
题目思路push 为先序遍历根据题目第一句话 pop为中序遍历即知道先序遍历和中序遍历来求得后序遍历的顺序根据先+中= 构建树根据树后序遍历在主函数中针对不同的字符串输入需要利用栈分别存在2个数组里。code # include <cstdio># include <queue># include <stack># include...原创 2019-03-26 22:00:25 · 216 阅读 · 0 评论 -
START BFS深度优先遍历-队列
题目寻找有几个块code#include<cstdio>#include <queue>using namespace std;const int maxn=100;struct node{ int x,y;}Node;int n,m;int matrix[maxn][maxn];bool inq[maxn][maxn]={false};//记...原创 2019-03-23 21:37:43 · 230 阅读 · 0 评论 -
PAT A1090 Highest Price in Supply Chain
code#include <cstdio>#include <algorithm>#include <vector>#include <cmath>using namespace std;const int maxn=10000;vector<int> child[maxn];double p,r;int n,maxDe...原创 2019-05-03 20:58:47 · 214 阅读 · 0 评论 -
PAT A1079 Total Sales of Supply Chain (25 point(s))
题目Code#include #include #include #include using namespace std;const int maxn=100100;struct node{double data;vector child;}Node[maxn];int n;double p,r,ans=0;void DFS(int index,int depth...原创 2019-05-03 21:24:30 · 213 阅读 · 0 评论 -
PAT A1106 Lowest Price in Supply Chain
题目找深度最小的叶子结点code#include <cstdio>#include <algorithm>#include <vector>#include <cmath>using namespace std;const int maxn=100100;const int INF=1e12;vector<int>N...原创 2019-05-13 21:45:46 · 189 阅读 · 0 评论 -
PAT A1004 Counting Leaves
题目计算每层各有多少叶子结点code#include <cstdio>#include <algorithm>#include <vector>#include <cmath>using namespace std;const int N=110;vector<int>G [N];int leaf[N]={0};/...原创 2019-05-13 22:06:57 · 169 阅读 · 0 评论 -
PAT A1097 Deduplication on a Linked List
题目code#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int maxn=100010;const int Table=100020;struct Node{//建立静态链表 int data; int next...原创 2019-03-19 20:54:45 · 145 阅读 · 0 评论 -
PAT B1036 跟奥巴马一起编程.图形输出类
题目code#include <iostream>#include <algorithm>#include <cstring>using namespace std;int main(){ int n,row; char a; scanf("%d %c",&n,&a); if(n%2==0) row=...原创 2019-03-11 13:23:23 · 215 阅读 · 0 评论 -
PAT B 1032 挖掘机技术哪家强
#include &lt;iostream&gt;#include &lt;algorithm&gt;#include &lt;string&gt;using namespace std;int main(){ int n,num,temp,a[1000001]; a[1000000]={0}; scanf("%d",&am原创 2019-03-08 21:40:53 · 143 阅读 · 0 评论 -
Codeup1928 日期处理
题目code#include <iostream>#include <algorithm>#include <cstring>#include <cmath>using namespace std;int isLeap(int year){ if(((year%4==0)&&(year%100!=0))||(ye...原创 2019-03-13 23:55:45 · 243 阅读 · 0 评论 -
PAT B1022 D进制的A+B
题目code#include <iostream>#include <algorithm>#include <cstring>#include <cmath>using namespace std;int main(){ int a,b,sum,d; scanf("%d%d%d",&a,&b,&..原创 2019-03-14 14:32:41 · 125 阅读 · 0 评论 -
PAT B1037 在霍格沃茨找零钱
题目code#include <iostream>#include <algorithm>#include <cstring>#include <cmath>using namespace std;const int Gallon=17*29;const int Sickle=29;int main(){ int ...原创 2019-03-14 14:58:59 · 157 阅读 · 0 评论 -
PAT B1028 人口普查
题目某城镇进行人口普查,得到了全体居民的生日。现请你写个程序,找出镇上最年长和最年轻的人。这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过 200 岁的老人,而今天是 2014 年 9 月 6 日,所以超过 200 岁的生日和未出生的生日都是不合理的,应该被过滤掉。输入格式:输入在第一行给出正整数 N,取值在(0,105 ];随后 N 行,每行给出 1 ...原创 2019-03-09 21:21:35 · 143 阅读 · 0 评论 -
PAT A1019 General Palindromic Number
题目code#include <iostream>#include <algorithm>#include <cstring>#include <cmath>using namespace std;bool Judge(int ans[],int num){ for(int i=0;i<num/2;i++){ ...原创 2019-03-14 15:56:58 · 191 阅读 · 0 评论 -
PAT 1001 A+B Format
题目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).Input Specification:Each input ...原创 2019-03-07 00:56:16 · 196 阅读 · 0 评论 -
PAT A1011 World Cup Betting
题目code#include <iostream>#include <algorithm>#include <string>using namespace std;int main(){ char S[3]={'W','T','L'};// s[0]=W s[1]=T s[2]=L double a,temp,sum; int i...原创 2019-03-10 13:41:38 · 162 阅读 · 0 评论 -
PAT A1027 Colors in Mars
题目请注意审题!你输入的数字decimaldecimaldecimaldecimaldecimaldecimaldecimaldecimaldecimaldecimaldecimaldecimaldecimaldecimal 10进制这个数变为火星上的13进制!!code#include <iostream>#include <algorithm>#inclu...原创 2019-03-14 16:33:51 · 166 阅读 · 0 评论 -
PAT A1058 A+B in Hogwarts
题目code#include <iostream>#include <algorithm>#include <cstring>#include <cmath>using namespace std;const int Galleon=17*29;const int Sickle=29;int main(){ long lo...原创 2019-03-14 18:24:30 · 175 阅读 · 0 评论 -
PAT A1036 Boys vs Girls 版本2有个小问题
题目This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one ...原创 2019-03-10 15:22:40 · 209 阅读 · 0 评论 -
PAT A1052 Linked List Sorting
题目code#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int maxn=100010;struct Node{ int data; int next; int address; bool flag...原创 2019-03-19 16:34:36 · 210 阅读 · 0 评论 -
PAT B1006 Sign In and Sign Out
题目code#include <iostream>#include <algorithm>#include <cstring>using namespace std;struct timel{ char id[20]; int HH; int MM; int SS;}Time_in,Time_out,Temp1,T...原创 2019-03-11 11:46:05 · 221 阅读 · 0 评论 -
PAT A1094 The Largest Generation (25 point(s))
#include <cstdio>#include <algorithm>#include <vector>#include <cmath>using namespace std;const int maxn=110;struct node{ int parent; vector<int> child;}id...原创 2019-05-06 22:11:54 · 155 阅读 · 0 评论