自定义博客皮肤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的专栏

相逢的人会再相逢

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

原创 4117:简单的整数划分问题

描述 将正整数n 表示成一系列正整数之和,n=n1+n2+…+nk, 其中n1>=n2>=…>=nk>=1 ,k>=1 。 正整数n 的这种表示称为正整数n 的划分。正整数n 的不同的划分个数称为正整数n 的划分数。 输入 标准的输入包含若干组测试数据。每组测试数据是一个整数N(0 < N <= 50)。 输出 对于每组测试数据,输出N的划分数...

2018-03-31 08:22:58 469

原创 4091:最近餐馆

描述 每到饭点,就又到了一日几度的小L纠结去哪吃饭的时候了。因为有太多太多好吃的地方可以去吃,而小L又比较懒不想走太远,所以小L会先找到距离他最近的M家餐馆然后再做筛选。 小L现在所在的位置和每家餐馆的位置用同一笛卡尔坐标系中的点表示,而点与点之间的距离为欧几里得距离,对于点p = (p1, p2,…, pn)和点q = (q1,q2,…, qn),两者的距离定义如下 现给出在K维空间中...

2018-03-24 21:27:18 1176

原创 [LeetCode] 84. Largest Rectangle in Histogram

Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each...

2018-03-24 13:41:16 166

原创 1144. The Missing Number (20)

1144. The Missing Number (20) #include <bits/stdc++.h> using namespace std; int main() { int n,val; vector<int> A; scanf("%d",&n); while(n--){ scanf("%d",&...

2018-03-21 18:43:25 407

原创 1145. Hashing - Average Search Time (25)

1145. Hashing - Average Search Time (25) #include <bits/stdc++.h> using namespace std; vector<int> v; int tsize,n,m; bool isprime(int n) { if(n<2) return 0; for(int i=2;i*i<...

2018-03-21 18:42:14 635

原创 1146. Topological Order (25)

1146. Topological Order (25) #include <bits/stdc++.h> using namespace std; vector<int> v[1024]; int indegree[1024]; bool isTopological(vector<int> &vx) { int n=vx.size(); ...

2018-03-21 18:40:58 359

原创 1147. Heaps (30)

1147. Heaps (30) #include <bits/stdc++.h> using namespace std; vector<int> A,v; int m,n; void postra(int i) { if(i<=n){ postra(2*i); postra(2*i+1); v.push_b...

2018-03-21 18:39:25 332

原创 [LeetCode] 64. Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at a...

2018-03-20 21:50:57 168

原创 1081. 检查密码 (15)

1081. 检查密码 (15) 可能不被注意的点:密码中可能出现空格,需要用gets或者getline读取整行,例如case2 #include <bits/stdc++.h> using namespace std; void passcheck(char pass[],int n) { if(n<6){ printf("Your password ...

2018-03-20 10:42:18 299

原创 1082. 射击比赛 (20)

1082. 射击比赛 (20) #include <bits/stdc++.h> using namespace std; int main() { int n; pair<string,int> maxp("",-1),minp("",0x7fffffff); cin>>n; while(n--){ strin...

2018-03-19 10:19:48 244

原创 1083. 是否存在相等的差 (20)

1083. 是否存在相等的差 (20) #include <bits/stdc++.h> using namespace std; map<int,int> mp; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;++i){ int val; s...

2018-03-19 10:18:31 277

原创 1084. 外观数列 (20)

1084. 外观数列 (20) 1140. Look-and-say Sequence (20) #include <bits/stdc++.h> using namespace std; string lasseq(string s) { string res; int len=s.size(),i=0; while(i<len){ ...

2018-03-19 09:55:35 1107

原创 1085. PAT单位排行 (25)

1085. PAT单位排行 (25) 1141. PAT Ranking of Institutions (25) #include <bits/stdc++.h> using namespace std; struct node { int rank; string school; int tws,ns; node(int r,string s,i...

2018-03-19 09:54:07 1310

原创 1143. Lowest Common Ancestor (30)

1143. Lowest Common Ancestor (30) #include <bits/stdc++.h> using namespace std; struct TreeNode { int val; TreeNode *left,*right; TreeNode(int v):val(v),left(NULL),right(NULL){} }; ...

2018-03-19 09:50:57 450

原创 1142. Maximal Clique (25)

1142. Maximal Clique (25) #include <bits/stdc++.h> using namespace std; vector<int> v[256]; int A[256][256]; void judge(vector<int> &seq) { int n=seq.size(),visit[256]={};...

2018-03-19 08:54:56 224

原创 1141. PAT Ranking of Institutions (25)

1141. PAT Ranking of Institutions (25) #include <bits/stdc++.h> using namespace std; struct node { int rank; string school; int tws,ns; node(int r,string s,int t,int n):rank(r),...

2018-03-19 08:37:46 409

原创 1140. Look-and-say Sequence (20)

1140. Look-and-say Sequence (20) #include <bits/stdc++.h> using namespace std; string lasseq(string s) { string res; int len=s.size(),i=0; while(i<len){ res+=s[i]; ...

2018-03-19 08:33:55 239

原创 缺失数

Problem Description 输入N个整数,求缺失的最小正整数,即1、2、3、…中不存在于这N个整数中的最小数。例如-3、-1、0、1、2、4、6中缺失的最小正整数为3。注意这N个整数可能无序。 Input 每个输入文件一组数据。 对每组数据,第一行为一个整数N(0 <= N <= 10^7),表示整数的个数; 第二行为N个整数,每个整数的绝对值都不超过10^18。...

2018-03-16 09:07:27 309

原创 宇宙树

Problem Description 在传承至今的典籍中认为,每个宇宙都是十种宇宙中的一种:炎之宇宙、光之宇宙、冰之宇宙、风之宇宙、雷之宇宙、土之宇宙、水之宇宙、木之宇宙、钢之宇宙、暗之宇宙,各表示了一个宇宙内部的主要元素。在最初始的大爆炸之后,在混沌中产生了最初的若干个宇宙,这些宇宙的类型是以上十种之一,可能相同,可能不同。从这些宇宙开始,每过一个纪元,各个宇宙都有可能孕育出多个新的宇宙(类...

2018-03-15 22:41:01 1127

原创 万妖瞬击

Problem Description “万妖穴中有若干小穴,每处小穴中皆有一只恶妖。小穴外设有封印,汝需消灭指定几处小穴中的恶妖方能解除该小穴封印,进而消灭穴中恶妖。” “此处石壁所刻便是万妖穴中各穴的封印解除关系。” “吾将瞬雷之法授于汝,汝消灭万妖穴中任一小穴皆仅需一瞬,愿汝尽快消灭各穴恶妖。” “然消灭小穴后,其对下一处小穴的封印加强通道仍需若干时间方能闭上。” “万妖穴中气息诡...

2018-03-13 11:50:06 797

原创 千姿百态

Problem Description 对一棵N个给定结点的二叉树或二叉搜索树(BST)来说,可以有很多种形态。 例如对3个结点的二叉树来说,就有以下5种二叉树形态: 现在给出一个正整数N,表示结点个数,求二叉树或二叉搜索树有多少种形态。 Input 每个输入文件一组数据。 对每组数据,输入两个整数F、N(F == 0 || F == 1, 1<= N <= 1000)...

2018-03-13 09:01:25 640

原创 龙龙跳跳跳

当电脑没有网络时,打开Chrome浏览器会发现一个恐龙小游戏: 按空格之后就可以开始玩: 你的任务是操纵一只呆萌的小恐龙来穿越沙漠。每次你按一下空格,小恐龙就会跳一下,形成一个完美的倒抛物线,并且每次跳跃的纵向距离和横向距离都是一样的。但是在沙漠中会有很多仙人掌,天上还会飞一些翼龙,你需要让你的小恐龙通过跳跃来避开这些仙人掌和翼龙,这就是整个游戏过程。 为了问题的简化,我们假设这是一个二...

2018-03-13 08:45:15 1176

原创 4087:数据筛选

总时间限制: 10000ms 单个测试点时间限制: 5000ms 内存限制: 3000kB 描述 小张需要从一批数量庞大的正整数中挑选出第k小的数,因为数据量太庞大,挑选起来很费劲,希望你能编程帮他进行挑选。 输入 第一行第一个是数据的个数n(10<=n<=10^6),第二个是需要挑选出的数据的序号k(1<=k<=10^5),n和k以空格分隔; 第二行以后是n个数...

2018-03-13 08:41:27 486

原创 万妖穴

Problem Description “万妖穴中有若干小穴,每处小穴中皆有一只恶妖。小穴外设有封印,汝需消灭指定几处小穴中的恶妖方能解除该小穴封印,进而消灭穴中恶妖。” “此处石壁所刻便是万妖穴中各穴的封印解除关系。” “万妖穴中或有部分小穴未设封印,汝可以此作为突破口。” “吾将根据石壁所示,将各穴消灭顺序给予汝,汝自珍重。” Input 每个输入文件中一组数据。 第一行两个正整...

2018-03-11 20:00:57 465

原创 进击的二叉查找树

Problem Description 给定1~N的两个排列,使用这两个排列分别构建两棵二叉查找树(也就是通过往一棵空树中依次插入序列元素的构建方式)。如果这两棵二叉查找树完全相同,那么输出YES;否则输出NO。之后,输出第一个排列对应的二叉查找树的后序序列、层序序列。 Input 每个输入文件中一组数据。 第一行1个正整数N(1<=N<=30),表示二叉查找树中的结点个数。 ...

2018-03-11 19:56:18 408

原创 2787:算24

总时间限制: 3000ms 内存限制: 65536kB 描述 给出4个小于10个正整数,你可以使用加减乘除4种运算以及括号把这4个数连接起来得到一个表达式。现在的问题是,是否存在一种方式使得得到的表达式的结果等于24。 这里加减乘除以及括号的运算结果和运算的优先级跟我们平常的定义一致(这里的除法定义是实数除法)。 比如,对于5,5,5,1,我们知道5 * (5 – 1 / 5) = 24,...

2018-03-11 14:09:39 631

原创 [LeetCode] 746. Min Cost Climbing Stairs

On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of ...

2018-03-04 11:18:07 169

原创 1001. Battle Over Cities - Hard Version (35)

题目地址:1001. Battle Over Cities - Hard Version (35) #include <bits/stdc++.h> using namespace std; struct Edge { int x,y,w,s; Edge(int a,int b,int c,int d):x(a),y(b),w(c),s(d){} bool...

2018-03-02 14:31:07 447

空空如也

空空如也

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

TA关注的人

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