自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 博客说明—最后的文章

截止目前为止,加入博客园已是一年光景,说来惭愧,当初注册这个账号时是由于看中了博客园的个性皮肤,但是,到目前为止,在博客园中,我却很少在这里发过文章(大部分,可能是全部目前为止的博文(约94%),都是从csdn上搬家过来的),相比博客园,csdn我觉得比较好的可以很容易进行文章整理和阅读(也可能是我更加倾向于使用csdn的博客),今天是2017年9月21日,在再次导入了csdn的文章后,...

2017-09-21 20:23:00 99

转载 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 ...

2017-09-21 13:33:00 156

转载 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] appe...

2017-09-21 13:31:00 139

转载 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个测试用例...

2017-09-21 13:22:00 85

转载 1074. 宇宙无敌加法器(20)

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

2017-09-21 13:14:00 55

转载 1073. 多选题常见计分法(20)

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

2017-09-21 13:08:00 112

转载 1072. 开学寄语(20)

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

2017-09-21 09:00:00 58

转载 1071. 小赌怡情(15)

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

2017-09-21 08:32:00 34

转载 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 a...

2017-09-17 22:36:00 58

转载 1135. Is It A Red-Black Tree (30)

There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The roo...

2017-09-17 22:00:00 202

转载 [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=l...

2017-09-11 11:33:00 51

转载 trie树(字典树)实现 C++

#include <iostream>#include <vector>#include <string>#include <map>using namespace std;struct TrieNode{ vector<TrieNode*> next; bool e...

2017-09-08 18:48:00 94

转载 [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; }...

2017-09-05 13:46:00 58

转载 C++ 11 Lambda表达式

本文转载 自d's'w846C++ 11 Lambda表达式C++11的一大亮点就是引入了Lambda表达式。利用Lambda表达式,可以方便的定义和创建匿名函数。对于C++这门语言来说来说,“Lambda表达式”或“匿名函数”这些概念听起来好像很深奥,但很多高级语言在很早以前就已经提供了Lambda表达式的功能,如C#,Python等。今天,我...

2017-09-05 11:02:00 54

转载 [LeetCode] 22. Generate Parentheses

void pHelp(vector<vector<int>> &res,vector<int> &rp,vector<int> &nums,unordered_map<int,int> &vis){ if(rp.size()==nums.size()) {...

2017-09-03 13:09:00 60

转载 [LeetCode] 526. Beautiful Arrangement

void caHelp(int &res,vector<int> &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)...

2017-09-03 12:25:00 95

转载 [LeetCode] 78. Subsets

void ssHelp(vector<vector<int>> &res,vector<int> &nums,vector<int> &rp,unsigned int cur){ res.push_back(rp); for(unsigned int i=cur;i<n...

2017-09-03 11:49:00 54

转载 n皇后问题—回溯法 C++实现

#include <iostream>#include <vector>using namespace std;bool isLegal(int row,int col,vector<string> &v,int n){ for(int i=0;i<row;++i) if(v[i][col...

2017-09-02 22:18:00 929

转载 [LeetCode] 103. Binary Tree Zigzag Level Order Traversal

void zzloHelp(vector<vector<int>> &res,unsigned int lev,TreeNode *r){ if(!r)return; if(lev+1>res.size()) { res.push_back(vector<int>()); } res[l...

2017-09-02 18:42:00 60

转载 [LeetCode] 662. Maximum Width of Binary Tree

void wbtHelp(vector<int> &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(m...

2017-09-02 18:29:00 144

转载 [LeetCode] 107. Binary Tree Level Order Traversal II

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

2017-09-02 17:51:00 52

转载 [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 dia...

2017-09-02 16:54:00 51

转载 [LeetCode] 637. Average of Levels in Binary Tree

void aveLevHelp(vector<double> &res,vector<int> &cnt,unsigned int lev,TreeNode *r){ if(r==NULL) return; if(lev+1>res.size()) { res.push_back(0); c...

2017-09-02 15:32:00 149

转载 [LeetCode] 1. Two Sum

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

2017-09-01 00:12:00 62

转载 [LeetCode] 442. Find All Duplicates in an Array

题解来自点击打开链接,vector<int> findDuplicates(vector<int>& nums){ vector<int> res; for(unsigned int i=0;i<nums.size();++i) { nums[abs(nums[i])-1]=-nums[a...

2017-08-31 23:06:00 48

转载 [LeetCode] 40. Combination Sum II

注意和39题区别,当前层值相同则跳过回溯法void cb2help(vector<vector<int>> &res,vector<int> &v,int target,unsigned int i,vector<int> recp){ if(target<0) return...

2017-08-31 22:39:00 43

转载 [LeetCode] 650. 2 Keys Keyboard

题目链接:点击打开链接关键词:dpint minSteps(int n){ vector<int> dp(n+1,1024); dp[1]=0; for(int i=2;i<=n;++i) { for(int k=1;k*k<=i;++k) { if(i%k==0) dp[i]=min(min...

2017-08-31 13:43:00 46

转载 [LeetCode] 39. Combination Sum

回溯法即可void cbhelp(vector<vector<int>> &res,vector<int> &v,int target,int i,vector<int> recp){ if(target<0) return; else if(target==0) { ...

2017-08-31 12:03:00 81

转载 [LeetCode] 560. Subarray Sum Equals K

int subarraySum(vector<int>& nums, int k){ int cnt=0,n=nums.size(),sum=0; vector<int> acc(n+1,0); acc[0]=0; for(int i=0;i<n;++i) { sum+=nums[i]; a...

2017-08-30 13:49:00 83

转载 数列最大连续子数组和

一、分治法: 算法复杂度:O(nlgn)#include <iostream>#include <vector>using namespace std;int A[]={-2,1,-3,4,-1,2,1,-5,4};int CrossSubArray(int A[],int low,int high,int mid)...

2017-08-27 10:40:00 64

转载 Huffman编码压缩和解压文档,C++实现

注:本演示代码采用自上而下得到huffman编码(二叉树) 关于huffman树及相关算法这里就略过,这里探讨的是如何进行编码和解压缩。先说一下大致步骤 1.首先,读取文档(txt格式),将其存入string类型的变量pretext里 2.进行词频统计 3.创建Huffman树,并以此得到各字符的二进制编码 4.对pretext进行遍历,通过上...

2017-08-24 17:37:00 1096

转载 ccf 地铁修建

问题描述   A市有n个交通枢纽,其中1号和n号非常重要,为了加强运输能力,A市决定在1号到n号枢纽间修建一条地铁。   地铁由很多段隧道组成,每段隧道连接两个交通枢纽。经过勘探,有m段隧道作为候选,两个交通枢纽之间最多只有一条候选的隧道,没有隧道两端连接着同一个交通枢纽。   现在有n家隧道施工的公司,每段候选的隧道只能由一个公司施工,每家公司施...

2017-08-22 22:28:00 65

转载 最小生成树 kruskal算法 C++实现

#include <iostream>#include <vector>#include <algorithm>#define Inf 0x7fffffffusing namespace std;struct node{ int u,v; int w; node(int a,int ...

2017-08-22 21:47:00 390

转载 最小生成树 prim算法 C++实现

#include <iostream>#include <vector>#define Inf 0x7fffffffusing namespace std;int main(){ int n,m;//节点个数和边数 cin>>n>>m;//输入节点个数和边数; vector...

2017-08-22 21:10:00 452

转载 ccf 最优灌溉

问题描述   雷雷承包了很多片麦田,为了灌溉这些麦田,雷雷在第一个麦田挖了一口很深的水井,所有的麦田都从这口井来引水灌溉。   为了灌溉,雷雷需要建立一些水渠,以连接水井和麦田,雷雷也可以利用部分麦田作为“中转站”,利用水渠连接不同的麦田,这样只要一片麦田能被灌溉,则与其连接的麦田也能被灌溉。   现在雷雷知道哪些麦田之间可以建设水渠和建设每个水渠...

2017-08-22 15:24:00 59

转载 ccf 高速公路

问题描述   某国有n个城市,为了使得城市间的交通更便利,该国国王打算在城市之间修一些高速公路,由于经费限制,国王打算第一阶段先在部分城市之间修一些单向的高速公路。   现在,大臣们帮国王拟了一个修高速公路的计划。看了计划后,国王发现,有些城市之间可以通过高速公路直接(不经过其他城市)或间接(经过一个或多个其他城市)到达,而有的却不能。如果城市A可以...

2017-08-22 13:56:00 42

转载 强连通分量 tarjan算法 C++实现

tarjan(u){  DFN[u]=Low[u]=++Index // 为节点u设定次序编号和Low初值  Stack.push(u) // 将节点u压入栈中  for each (u, v) in E // 枚举每一条边    if (v is not visted) // 如果节点v未被访问过        tarjan(v...

2017-08-22 13:35:00 464

转载 ccf 送货

问题描述   为了增加公司收入,F公司新开设了物流业务。由于F公司在业界的良好口碑,物流业务一开通即受到了消费者的欢迎,物流业务马上遍及了城市的每条街道。然而,F公司现在只安排了小明一个人负责所有街道的服务。   任务虽然繁重,但是小明有足够的信心,他拿到了城市的地图,准备研究最好的方案。城市中有n个交叉路口,m条街道连接在这些交叉路口之间,每条街道...

2017-08-21 23:48:00 79

转载 you-get 使用总结

you-get 是py上一个方便的下载工具项目主页:https://github.com/soimort/you-get You-Get 主页:https://you-get.org/ You-Get 原版中文说明:https://github.com/soimort/you-get/wiki/中文说明/ 作者:soimort安装: 未安...

2017-08-18 09:33:00 5565

转载 [LeetCode] 4.Median of Two Sorted Arrays

原题链接:Median of Two Sorted Arrays 题目大意是,给你两个已经排好序的数组,找到这两个数组的中位数 比如:Example 1:nums1 = [1, 3]nums2 = [2]The median is 2.0又比如:Example 2:nums1 = [1, 2]nums2 = [3, 4...

2017-08-17 13:36:00 76

空空如也

空空如也

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

TA关注的人

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