自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

L_Aster的专栏

相逢的人会再相逢

  • 博客(40)
  • 收藏
  • 关注

原创 PAT甲级解题报告索引

PAT甲级题目地址:https://www.patest.cn/contests/pat-a-practisePAT甲级代码Github仓库已经整理更新完毕,包含最新全部代码(C++),部分代码已经加以注解,并使用尽量简单的解题思路以及简洁的代码实现:我的 Github|甲级 欢迎star或者fork,以及讨论交流关于博客,大部分已经和github同步,但是部分未更新,可能的原因有: ...

2017-09-22 23:15:43 2482

原创 PAT乙级解题报告索引

PAT乙级题目地址:https://www.patest.cn/contests/pat-b-practise/ PAT乙级的所有题目题解收录于此 最新的代码在github仓库Github | PAT乙级 欢迎交流讨论 博客有些代码未同步1001. 害死人不偿命的(3n+1)猜想 (15) 1002. 写出这个数 (20) 1003. 我要通过!(20) 1004. 成绩排名 (...

2017-09-22 20:21:52 1414

原创 将C++代码转化为高亮的html代码

用Mathematica实现,功能比较简单,利用正则表达式对相应位置加上html标签< span >即可,写这个的初衷是csdn的代码渲染看起来不是很好看,而且之前刷PAT来着,如果用import爬取问题描述,然后连接成一篇article也比较方便(难道不是因为懒吗(逃~))code = Import["C:\\Users\\gl486\\Desktop\\nb\\cpp.txt"];(*读入代码*

2017-09-28 18:26:38 1720

转载 正则表达式全部符号解释

字符描述\将下一个字符标记为一个特殊字符、或一个原义字符、或一个 向后引用、或一个八进制转义符。例如,'n' 匹配字符 "n"。'\n' 匹配一个换行符。序列 '\\' 匹配 "\" 而 "\(" 则匹配 "("。^匹配输入字符串的开始位置。如果设置了 RegExp 对象的 Multiline 属性,^ 也匹配 '\n' 或 '\r' 之后的位置。$

2017-09-28 17:38:31 219

原创 mathematica StringCases和StringReplace,Regex

StringCases["shdhd1.23333--12-10000/233.2 -23 123 A+12AAAA-1929", RegularExpression["[+-]?[0-9]+\.?[0-9]+"]] {"1.23333", "-12", "-10000", "233.2", "-23", "123", "+12", "-1929"}StringReplace["shdhd1.2

2017-09-28 16:24:58 375

原创 Mathematica 获取豆瓣图书top250,正则表达式

mathematica的Import除了可以从文件中导入数据之外,还可以方便的从任何可访问的网页中导入数据,例如Import["https://book.douban.com/top250"]通过加入Elements,可以查看可用的元素Import["https://book.douban.com/top250", "Elements"]{"Data", "FullData", "Hyperlin

2017-09-28 15:39:39 638

原创 stdc++.h

里面内容如下: (文件摘录自devcpp安装目录下 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\x86_64-w64-mingw32\32\bits)// C++ includes used for precompiling -*- C++ -*-// Copyright

2017-09-27 16:39:55 545

原创 C++ 反转字符串

C++ < algorithm >中的reverse函数可以方便的帮助你反转一个string类型的字符串 一个简要介绍C++ reverse 例如:string str="12345";reverse(str.begin(),str.end());cout<<str;//输出str结果为"54321"你也可以通过使用C语言中的strrev来反转一个char类型的字符串,如果你是string类

2017-09-23 19:46:31 15421 1

原创 C++ reverse

C++ algorithm 中定义的reverse函数用于反转在该范围内的顺序template <class BidirectionalIterator>void reverse (BidirectionalIterator first,BidirectionalIterator last);vector<int> v={1,2,3,4,5};reverse(v.begin(),v.end())

2017-09-23 19:16:03 16349

原创 C++ iter_swap()

C++ algorithm中定义的iter_swap,用于交换两个迭代器所指向的值 例如vector<int> v={1,2,3,4,5};iter_swap(v.begin(),--v.end());//v的值为5,2,3,4,1int a[]={1,2,3,4,5};iter_swap(a,a+1);//a的值为2,1,3,4,5

2017-09-23 19:05:10 1206

原创 1007. Maximum Subsequence Sum (25)

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. TheMaximum Subsequence is the continuous subsequence which

2017-09-23 12:43:32 482 1

原创 1088. Rational Arithmetic (20)

For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test case,...

2017-09-22 22:49:05 216

原创 1070. Mooncake (25)

Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now

2017-09-22 20:50:02 231

原创 1008. Elevator (20)

The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec

2017-09-22 20:12:11 314

原创 1052. Linked List Sorting (25)

A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and aNext pointer to the next structure. Now giv

2017-09-22 14:43:54 202

原创 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. Eac

2017-09-22 14:25:31 215

原创 1001. A+B Format (20)

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).InputEach input file contains

2017-09-22 14:19:21 454

原创 1132. Cut Integer (20)

Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting

2017-09-21 13:32:38 279

原创 1133. Splitting A Linked List (25)

Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea

2017-09-21 13:31:23 291

原创 1075. 链表元素分类(25)

给定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而[0, K]区间内的元素都排在大于K的元素前面。但每一类内部元素的顺序是不能改变的。例如:给定链表为 18→7→-4→0→5→-6→10→11→-2,K为10,则输出应该为 -4→-6→-2→7→0→5→10→18→11。输入格式:每个输入包含1个测试用例。每个测试用例第1行给出:第1个结点的地址;

2017-09-21 13:21:43 700

原创 1074. 宇宙无敌加法器(20)

地球人习惯使用十进制数,并且默认一个数字的每一位都是十进制的。而在PAT星人开挂的世界里,每个数字的每一位都是不同进制的,这种神奇的数字称为“PAT数”。每个PAT星人都必须熟记各位数字的进制表,例如“……0527”就表示最低位是7进制数、第2位是2进制数、第3位是5进制数、第4位是10进制数,等等。每一位的进制d或者是0(表示十进制)、或者是[2,9]区间内的整数。理论上这个进制表应该包含无穷多...

2017-09-21 13:13:47 1954

原创 1073. 多选题常见计分法(20)

批改多选题是比较麻烦的事情,有很多不同的计分方法。有一种最常见的计分方法是:如果考生选择了部分正确选项,并且没有选择任何错误选项,则得到50%分数;如果考生选择了任何一个错误的选项,则不能得分。本题就请你写个程序帮助老师批改多选题,并且指出哪道题的哪个选项错的人最多。输入格式:输入在第一行给出两个正整数N(输出格式:按照输入的顺序给出每个学生的得分,每个分数占一行,输出小数点后1位

2017-09-21 13:07:51 1167

原创 1072. 开学寄语(20)

下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其QQ,封其电脑,夺其手机,收其ipad,断其wifi,使其百无聊赖,然后,净面、理发、整衣,然后思过、读书、锻炼、明智、开悟、精进。而后必成大器也!本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器。输入格式:输入第一行给出两个正整数N(输出格式:顺次检查每个学生携带的物品,如果有需要被

2017-09-21 08:59:51 370

原创 1071. 小赌怡情(15)

1071. 小赌怡情(15)常言道“小赌怡情”。这是一个很简单的小游戏:首先由计算机给出第一个整数;然后玩家下注赌第二个整数将会比第一个数大还是小;玩家下注t个筹码后,计算机给出第二个数。若玩家猜对了,则系统奖励玩家t个筹码;否则扣除玩家t个筹码。注意:玩家下注的筹码数不能超过自己帐户上拥有的筹码数。当玩家输光了全部筹码后,游戏就结束。输入格式:输入在第

2017-09-21 08:31:51 316

原创 1134. Vertex Cover (25)

A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if each of them is a vertex cover or not.题目的大意是:给你一张图,对于图中的

2017-09-17 22:35:56 317

原创 1135. Is It A Red-Black Tree (30)

https://www.patest.cn/contests/pat-a-practise/1135#include &lt;bits/stdc++.h&gt;using namespace std;vector&lt;int&gt; pre,ino;struct TreeNode{ int val; TreeNode *left,*right; TreeNode(int v=0,T...

2017-09-17 21:59:51 637

原创 [LeetCode] 143. Reorder List

void reorderList(ListNode* head){ if(head==NULL||head->next==NULL) return; ListNode *l1=head,*l2=head->next; while(l2&&l2->next) { l1=l1->next; l2=l2->next->next; } ListNode *h=l1-

2017-09-11 11:33:01 213

原创 trie树(字典树)实现 C++

#include <iostream>#include <vector>#include <string>#include <map>using namespace std;struct TrieNode{ vector<TrieNode*> next; bool end; int cnt; TrieNode():end(0),cnt(0){}};Tr

2017-09-08 18:47:54 679

原创 [LeetCode] 547. Friend Circles

int findCircleNum(vector<vector<int>>& M){ int n=M.size(); vector<int> parents(n,0); for(int i=0;i<n;++i) { parents[i]=i; } function<int(int,vector<int>&)>finds=[&finds

2017-09-05 13:45:47 302

转载 C++ 11 Lambda表达式

C++11的一大亮点就是引入了Lambda表达式。利用Lambda表达式,可以方便的定义和创建匿名函数。对于C++这门语言来说来说,“Lambda表达式”或“匿名函数”这些概念听起来好像很深奥,但很多高级语言在很早以前就已经提供了Lambda表达式的功能,如C#,Python等。今天,我们就来简单介绍一下C++中Lambda表达式的简单使用。声明Lambda表达式Lambda表达式完整的声

2017-09-05 11:01:36 318

原创 [LeetCode] 22. Generate Parentheses

void pHelp(vector> &res,vector &rp,vector &nums,unordered_map &vis){ if(rp.size()==nums.size()) { res.push_back(rp); return; } for(unsigned int i=0;i<nums.size();++i) { if(vis[num

2017-09-03 13:08:46 196

原创 [LeetCode] 526. Beautiful Arrangement

void caHelp(int &res,vector &v,int N,int cnt){ if(cnt==N+1) { ++res; return; } for(int i=1;i<=N;++i) { if(v[i]==0&&(i%cnt==0||cnt%i==0)) { v[i]=1; caHelp(res,v,N,cnt+1)

2017-09-03 12:24:38 227

原创 [LeetCode] 78. Subsets

void ssHelp(vector> &res,vector &nums,vector &rp,unsigned int cur){ res.push_back(rp); for(unsigned int i=cur;i<nums.size();++i) { rp.push_back(nums[i]); ssHelp(res,nums,rp,i+1); rp.p

2017-09-03 11:49:21 223

原创 n皇后问题—回溯法 C++实现

#include #include using namespace std;bool isLegal(int row,int col,vector &v,int n){ for(int i=0;i<row;++i) if(v[i][col]=='Q') return false; for(int i=row-1,j=col-1;i>=0&&j>=0;--i,--j)

2017-09-02 22:18:13 3441

原创 [LeetCode] 103. Binary Tree Zigzag Level Order Traversal

void zzloHelp(vector> &res,unsigned int lev,TreeNode *r){ if(!r)return; if(lev+1>res.size()) { res.push_back(vector()); } res[lev].push_back(r->val); zzloHelp(res,lev+1,r->left); zz

2017-09-02 18:42:24 188

原创 [LeetCode] 662. Maximum Width of Binary Tree

void wbtHelp(vector &lf,int idx,unsigned int lev,int &maxwid,TreeNode *r){ if(r==NULL) return; if(lev+1>lf.size()) lf.push_back(idx); else maxwid=max(maxwid,idx+1-lf[lev]); wbtHelp(lf,2*idx,

2017-09-02 18:29:27 591

原创 [LeetCode] 107. Binary Tree Level Order Traversal II

void lobHelp(vector> &res,unsigned int lev,TreeNode *r){ if(r==NULL) return; if(lev+1>res.size()) { res.push_back(vector()); } res[lev].push_back(r->val); lobHelp(res,lev+1,r->left);

2017-09-02 17:51:04 312

原创 [LeetCode] 543. Diameter of Binary Tree

int dbHelp(TreeNode *r,int &res){ if(!r)return 0; int lh=dbHelp(r->left,res)+1; int rh=dbHelp(r->right,res)+1; res=max(res,lh+rh-2); return max(lh,rh);}int diameterOfBinaryTree(TreeNod

2017-09-02 16:54:17 198

原创 [LeetCode] 637. Average of Levels in Binary Tree

void aveLevHelp(vector &res,vector &cnt,unsigned int lev,TreeNode *r){ if(r==NULL) return; if(lev+1>res.size()) { res.push_back(0); cnt.push_back(0); } res[lev]+=r->val; cnt[lev]++

2017-09-02 15:32:09 425

原创 [LeetCode] 1. Two Sum

vector twoSum(vector& nums, int target){ unordered_map hash; int n=nums.size(); for(int i=0;i<n;++i) { if(hash[target-nums[i]]) return {i,hash[target-nums[i]]-1}; hash[nums[i]]=i+1; } retur

2017-09-01 00:12:04 172

空空如也

空空如也

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

TA关注的人

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