
PAT
刺猬1012
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PAT 1004. Counting Leaves (30)
1004. Counting Leaves (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A family hierarchy is usually presented by a pedigree tree.原创 2014-03-19 11:58:16 · 599 阅读 · 0 评论 -
PAT 1063. Set Similarity (25)
Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of distinct numb原创 2015-07-15 16:25:31 · 317 阅读 · 0 评论 -
PAT 1054. The Dominant Color (20)
方法一:排序,然后计算最多的且超过总数的1/2; 会超时 方法二:map的使用; 方法三:因为我们所要求的数出现的次数超过总数目一半,所以将不相同的数两两抵消,那么最终剩下的便是我们要求的数。当然这不是我能想到的。 方法二代码:#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<m原创 2015-07-15 14:15:22 · 364 阅读 · 0 评论 -
PAT 1039. Course List for Student (25)
一开始讲数据开到40000*2500内存超限,然后学习了其它人的代码,使用hash和vector。#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<string> #include<vector> using namespace std;vector<int> student[26*2原创 2015-07-31 14:27:54 · 320 阅读 · 0 评论 -
PAT 1051. Pop Sequence (25)
模拟进栈出栈问题。注意栈有大小。#include<iostream> #include<cstdio> #include<stack> using namespace std; int main() { int M,n,k; while(scanf("%d%d%d",&M,&n,&k) != EOF) { for(int i = 1; i <= k; i++)原创 2015-07-21 15:36:32 · 326 阅读 · 0 评论 -
PAT 1094. The Largest Generation (25)
好久没写BFS,还算顺利。#include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std;struct node { int next[101]; int num; int level; }Node[102];int level[102];void BFS()原创 2015-07-21 20:49:34 · 467 阅读 · 0 评论 -
PAT 1076. Forwards on Weibo (30)
其实这道题一直没怎么明白意思,晕乎乎的,自己按照数据凑出来的,醉了#include<iostream> #include<cstdio> #include<cstring> #include<queue>using namespace std;int n,l; bool follow[1001][1001]; int level[1001];int bfs(int t) { queue<in转载 2015-08-02 21:39:17 · 567 阅读 · 0 评论 -
PAT 1030. Travel Plan (30)
题目:http://www.patest.cn/contests/pat-a-practise/1030 考察最短路径问题,复习了一下dijkstra算法。 http://www.2cto.com/kf/201311/257005.html题目不仅要求最短路径还需要加权值#include<iostream> #include<cstdio> #include<cstring> using nam原创 2015-08-03 12:04:58 · 324 阅读 · 0 评论 -
PAT 1033. To Fill or Not to Fill (25)
这是个贪心的题目,不是很会,看了博客http://blog.youkuaiyun.com/sup_heaven/article/details/19006527 自己写了一遍,没过,按着作者的抄了一遍还是没过,最后真实要哭了,然后把关键代码又看了一遍。原创 2015-09-10 10:52:30 · 216 阅读 · 0 评论 -
PAT1021
不是很理解:http://blog.youkuaiyun.com/iaccepted/article/details/20454519,练习一下并查集原创 2015-09-11 16:01:57 · 302 阅读 · 0 评论 -
PAT 1013. Battle Over Cities (25)
考察并查集#include<iostream> #include<cstdio> #include<cstring>using namespace std;int tree[1001]; bool temp[1001][1001];struct node { int a; int b; }Edge[500002];int find(int x) { if(tree[x] ==原创 2015-09-11 22:57:23 · 273 阅读 · 0 评论 -
PAT 1085. Perfect Sequence (25)
一个很简单的题目,但是交了好几次都没有过,现在来分析一下: 第一次提交想当然的排序,然后找最小的,然后找到对应的最大值。 第二次是以为不是输出个数,是输出最大数,然后~ 第三次终于想清楚了,遍历加二分,但是为啥还有一个没过呢,最后实在没办法查了一下资料,发现10^9 * 10 ^9超出int范围,改成long long就OK了 代码如下:#include<iostream> #include原创 2015-07-08 16:00:55 · 522 阅读 · 0 评论 -
PAT 1078. Hashing (25)
今天打算把当年没有做对的几道题重新做一下。才发现自己有多么的low。 先把这道简单的题贴出来: 1078. Hashing (25)时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The task of this problem is simple: insert a sequence o原创 2015-07-07 14:32:27 · 406 阅读 · 0 评论 -
PAT 1096. Consecutive Factors (20)
虽然这道题很水,却用了自己不少时间,因为先是把题目看错了,接着就是想复杂了,和同学交流一下发现其实直接暴力就可以,也不会超时。 总共交了7次才过。 第一次交只算了sqrt(n)之前的因子 第二次交sqrt(n)+1 第三次交发现只算了一半的因子,然后添加 第四次交发现找出的因子可能相乘超过n,加了个判断 第五次交、第六次和第七次只是忘了考虑找到的因子能不能被n整除问题! 代码如下,比原创 2015-04-11 20:55:48 · 754 阅读 · 0 评论 -
PAT 1065. A+B and C (64bit) (20)
好吧,做别的长题看不下去只能去做个简单的题了。 先来看一下long double http://blog.sina.com.cn/s/blog_6ebd49350101gdgo.html #include #include using namespace std; int main() { int t; cin>>t; for(int原创 2015-04-14 22:02:43 · 320 阅读 · 0 评论 -
1009. Product of Polynomials (25)
这道题比较简单,貌似之前做过,但是为什么没有一次性过呢,原因是我把数组设置为1000的了,事实上需要1000+1000的数组才可以。 ps:学习了C++输出double保留一位小数,setiosflags(ios::fixed) #include #include #include #include using namespace std; struct p{ i原创 2015-04-14 20:41:07 · 665 阅读 · 0 评论 -
PAT 1002. A+B for Polynomials (25)
这个道题和1009相似,但是因为忘记结果可能小于0,就悲剧的交了好几次,依旧比较水,但总是不能想的全面,反思~ #include #include #include using namespace std; int main() { int k1,k2; while(cin>>k1) { double sum[1002];原创 2015-04-14 20:47:14 · 404 阅读 · 0 评论 -
1001. A+B Format (20)
之前账号丢失,重新刷一下PAT,迎接PAT考试。 这是一个非常水的题目,但是因为好久没有写C++,一开始导致不知道如何写起,还是按照以前的习惯来写的,一年发现自己没什么进步,以后要多拜读一下大神的code 代码如下: #include using namespace std; int main() { int a,b; while(cin>>a>>b) {原创 2015-04-09 22:13:26 · 352 阅读 · 0 评论 -
PAT 1077. Kuchiguse (20)
做PAT的时候发现当年复试时做的题目,当时因为紧张所以没有发挥好,居然以为第一道题是最难的,现在看看发现当时一定是脑袋短路了。 题目很简单,只需要将字符串逆序,然后按照最小的长度比较,相同的再逆序输出。 本来还以为题目会不会因为空格等字符卡题,现在想想其实这道题出的确实简单。#include<iostream> #include<cstdio> #include<cstring> using n原创 2015-05-20 19:32:06 · 328 阅读 · 0 评论 -
PAT 1046. Shortest Distance (20)
模拟 10^4 * 10^5 会超时,通过设置一个0点,通过计算每个点到0的距离,两点之间的最短距离只需要相减就可以了。 代码如下:#include<iostream> #include<cstdio> using namespace std; int main() { int n; while(cin>>n) { int d[100005],dis; d[0] = 0原创 2015-07-07 17:05:35 · 330 阅读 · 0 评论 -
PAT 1012. The Best Rank (25)
不得不写的1012,一把辛酸泪。 正常模拟排序之后中间两个一直过不了,然后看了别人的博客,发现问题: 1.并列排名问题没有考虑,然后再改改,发现依然没有过。 2.平均数是+0.5之后的整数,然后依旧没过。 最后我发现我傻帽的地方,考虑并列排名时居然用判断处理之后的了,已经哭瞎了,最后终于过了!#include<iostream> #include<cstdio> #include<cstri原创 2015-07-10 15:24:57 · 467 阅读 · 0 评论 -
PAT 1052. Linked List Sorting (25)
这道题和1074差不多,在一个链表上进行排序 1.首先将在一个链表的分离出来 2.排序 3**注意判断输入为0和输入head不存在的情况**#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<map> using namespace std;struct p { int add原创 2015-07-25 10:28:52 · 414 阅读 · 0 评论 -
PAT 1099. Build A Binary Search Tree (30)
这道题是二叉搜索树(BST)。 1.根据节点建树 2.把数组数排序 3.中序遍历二叉树,讲数据写入树中 4.层次遍历树#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> using namespace std;struct p { int left; int原创 2015-07-27 19:05:09 · 925 阅读 · 4 评论 -
PAT 1101. Quick Sort (25)
第一次参加PAT考试,遇到的第二道题,感觉很简单,但是智商余额不足,导致最后只想出来遍历的方法,还有一个陷阱是如果数据为0也要输出一个空行。最笨的方法也能得20分,只能说真给面子了。 看了大神们的代码,从前往后遍历,记录最大值,从后往前遍历,记录最小值,然后比较。#include<iostream> #include<cstdio> #include<algorithm> #include<cst原创 2015-09-21 11:21:12 · 1262 阅读 · 0 评论