甲级
PAT甲级 1002 A+B for Polynomials
原题链接: 本题需要将相同次数的项进行相加,因此在初始输入的时候就直接用数组记录每个次数项,下标为次数,值为对应次数项的值(用+=) 遍历整个数组,看有几个元素非0即可知非0项的个数。 因要求降幂输出,则从后向前遍历,输出每个元素的下标和值。 #include <bits/stdc++.h> usi ......
PAT甲级:1174 Left-View of Binary Tree
题目:1174 Left-View of Binary Tree 25分 题解:层次遍历输出每一行最左边的元素。(最开始以为输出部分节点的左子树...想不到思路) using namespace std; #include <iostream> #include <vector> #include ......
PAT 甲级【1015 Reversible Primes】
考察素数判断 考察进制转换 import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class Main { @SuppressWarnings("unc ......
PAT甲级【1014 Waiting in Line】
考察双向链表 import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.LinkedList; public class Main { ......
PAT 甲级【1013 Battle Over Cities】
本题就是dfs.连通图个数-2; 但是java慢,最后一个case 超时 import java.io.*; import java.util.HashSet; import java.util.Set; public class Main { @SuppressWarnings("uncheck" ......
PAT 甲级【1012 The Best Rank】
本题用java极容易超时,提交了好几次才成功 另外90 88 77 77 50,名次应该是1 2 3 3 5 ,不是1 2 3 3 4 import java.io.*; public class Main { @SuppressWarnings("unchecked") public static ......
PAT 甲级【1011 World Cup Betting】
import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class Main { @SuppressWarnings("unchecked") publi ......
PAT 甲级【1010 Radix】
本题范围long型(35)^10 枚举radix范围上限pow(n/a0,1/m)上,考虑上限加1.范围较大。使用二分查找枚举 代码如下 import java.io.BufferedReader; import java.io.IOException; import java.io.InputSt ......
PAT 甲级【1009 Product of Polynomials】
/* 系数为0不输出 貌似runtime异常也显示答案不正确*/import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamToke ......
PAT 甲级1008【1008 Elevator】
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class Main { @Supp ......
PAT 甲级【1007 Maximum Subsequence Sum】
本题是考察动态规划与java的快速输入: max[i]表示第i个结尾的最大的连续子串和。b begin[i]表示第[begin[i],i]为最大和的开始位置 超时代码: import java.io.BufferedReader; import java.io.IOException; import ......
PAT 甲级1005【1005 Spell It Right】
用JAVA可以用BigInteger解决。 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import ......
PAT 甲级考试【1003 Emergency】
PAT 甲级考试: dfs+dijktasla算法。 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public cla ......
PAT 甲级:1002 A+B for Polynomials,测试点说明
1002 A+B for Polynomials 25分 题解:(类似于把两个多项式合并同类项:指数相同的项把系数相加),最后输出新多项式的项数、各项。 需要注意的测试点: 1.输出的新项格式要与输入的一致:[项数] [指数1] [系数1] [指数2] [系数2] ...;且指数递减 2.指数是整型 ......
PAT-甲级-1007 Maximum Subsequence Sum C++
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1≤i≤j≤K. The Maximum S ......
PAT-甲级-1005 Spell It Right C++
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 Specificat ......
PAT-甲级-1004 Counting Leaves C++
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each inp ......
菜鸟记录:c语言实现PAT甲级1005--Spell It Right
非常简单的一题了,但还是交了两三次,原因:对数组的理解不足;对数字和字符之间的转换不够敏感。这将在下文中细说。 Given a non-negative integer N, your task is to compute the sum of all the digits of N, and ou ......
PAT 甲级 1015 Reversible Primes(20)
A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a re ......
菜鸟记录:c语言实现PAT甲级1004--Counting Leaves
好消息:与上题的Emergency是同样的方法。坏消息:又错了&&c++真的比c方便太多太多。 A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members ......
PAT 甲级 1014 Waiting in Line(30)
Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules ......
菜鸟记录PAT甲级1003--Emergency
久违的PAT,由于考研408数据结构中有一定需要,同时也是对先前所遗留的竞赛遗憾进行一定弥补 ,再次继续PAT甲级1003.。 As an emergency rescue team leader of a city, you are given a special map of your coun ......
PAT甲级真题1020.树的遍历
翻译和代码思路:Acwing 一个二叉树,树中每个节点的权值互不相同。 现在给出它的后序遍历和中序遍历,请你输出它的层序遍历。 输入格式 第一行包含整数 N,表示二叉树的节点数。 第二行包含 N个整数,表示二叉树的后序遍历。 第三行包含 N 个整数,表示二叉树的中序遍历。 输出格式 输出一行 N个整 ......