自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

转载 1103 integer factorization

dfs+pruneAC代码:#include <vector>#include <cstdio>#include <algorithm>#include <cmath>#include <numeric>using namespace std;class sol{public: ...

2016-03-11 23:15:00 174

转载 1098 insertion or heap sort

堆排序STL algorithm里有建堆make_heap,出栈 pop_heap(将堆首元素移至容器尾部),入栈push_heap,以及堆排序sort_heapAC代码#include <vector>#include <cstdio>#include <string>#include <algorithm>u...

2016-03-11 11:46:00 90

转载 1091 acute stroke

三维空间的DFS,挺新颖的一题AC代码:#include <vector>#include <cstdio>#include <queue>using namespace std;int x[] = {0,0,1,0,-1,0};int y[] = {0,1,0,-1,0,0};int z[] = {-1,0,0,0...

2016-03-10 22:59:00 101

转载 1090 highest price in supply chain

p,r用double类型,pat多题如果用float会WAAC代码#include <vector>#include <cstdio>#include <cmath>using namespace std;int main(){ int n; double p,r; scanf("%d %lf ...

2016-03-10 22:24:00 84

转载 1088

a x b = c将a,b,c用out统一输出AC代码:#include <cstdio>#include <string>using namespace std;long long gcd(long long x,long long y){ if(x == 0) return y; if(y ==...

2016-03-10 20:52:00 162

转载 1082 read number in chinese

注意0的情况AC代码:#include <string>#include <iostream>#include <vector>using namespace std;string number[] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};st...

2016-03-09 22:49:00 65

转载 1079 total sales of supply chain

BFS,用递归的话会段错误,改用vector,变量idx记录下一层的起点AC代码:#include <vector>#include <cstdio>#include <map>using namespace std;/*void bfs(vector<vector<int>>& g,vect...

2016-03-09 19:44:00 79

转载 1075 pat judge

最后一个测试点一直通不过,琢磨了一上午,终于找出bug主要原因:考生k的第一个成绩是-1的情况,应将这项成绩记下,至于k是否所有提交的成绩都是-1,通过设置成员变量AC来判断,AC为true,写入vector参加后续排序,AC为false,不写入vector不参加后续排序。AC代码:#include <algorithm>#include <vect...

2016-03-09 11:39:00 139

转载 1074 reverse list

最后一个测试用例很坑,注意给出的n个节点不一定都在以h为头的链表上,这种测试用例在PAT链表相关的问题中多次出现,要予以注意。AC代码#include <vector>#include <map>#include <algorithm>#include <cstdio>using namespace std;...

2016-03-09 00:04:00 79

转载 1071 speech pattern

#include <string>#include <sstream>#include <map>#include <vector>#include <iostream>using namespace std;int main(){ vector<string> v; ...

2016-03-08 20:26:00 150

转载 1065 a+b and c(64)

做得比较乱,修改多次后终于AC#include <string>#include <iostream>#include <algorithm>using namespace std;bool cmp(string a,string b){ if(a == b) return false; i...

2016-03-08 10:54:00 136

转载 pop sequence

两个set维护在stack中和不在stack中的元素,priority_queue维护在stack中的最大元素AC代码#include <set>#include <iostream>#include <queue>#include <cstdio>#include <vector>using n...

2016-03-03 21:12:00 82

转载 1049 counting ones

从所有一位数包含的1开始向上递推所有k位数包含的1,递推式:ak = ak-1 * 10 + pow(10,k-1);AC代码:#include <vector>#include <cstdio>using namespace std;int main(){ int n; vector<int> rec;...

2016-03-03 20:26:00 74

转载 1040 the longest symmetric

以每个字符为中心,分两种情况向两边扩展。manacher算法参见http://www.cnblogs.com/houkai/p/3371807.htmlAC代码:#include <string>#include <cstdio>#include <iostream>using namespace std;int mai...

2016-03-02 16:24:00 96

转载 1039 course list for student

最后一点用string 和cin会超时将学生名字转换成int用scanf就可以了AC代码:#include <vector>#include <string>#include <map>#include <set>#include <cstdio>#include <iostream&g...

2016-03-02 16:03:00 160

转载 1038 recover the smallest number

注意:最小数为0时,要输出“0”AC代码#include <string>#include <vector>#include <algorithm>#include <iostream>using namespace std;bool cmp(const string& a,const string&...

2016-03-02 12:42:00 71

转载 1035 head of a gang

简单并查集AC代码#include <map>#include <string>#include <iostream>#include <cstdio>#include <vector>using namespace std;string find(map<string,string&g...

2016-03-01 23:40:00 67

转载 1033 to fill or not to fill

贪心算法注意两点:1、sum用double类型2、第二个测试点是起点没有加油站的情况AC代码 1 #include <vector> 2 #include <cstdio> 3 #include <algorithm> 4 #include <map> 5 using namespace s...

2016-03-01 22:32:00 99

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除