自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 C++插入排序的递归算法

C++插入排序的递归算法收获:关于执行操作与调用递归的顺序的思考,例如插入排序应该先调用递归再执行操作,这样能得到最内层的结果,一层层返回到外层。代码:#include <iostream>#include<stdio.h>//#define _CRT_SECURE_NO_DEPRECATE//#pragma warming(disable:4996)using namespace std;void sort(int arr[], int k){ if (k ==

2021-03-17 13:00:05 694

原创 2021.2.4codeup1928

codeup 1928 答案错误对着书上差不多写的,答案一直通过不了,最后发现是输出时没换行。。。#include <iostream>#include<stdio.h>//#define _CRT_SECURE_NO_DEPRECATE//#pragma warming(disable:4996)using namespace std;int month[13][2] ={ {0,0}, {31,31},{28,29},{31,31},{30,30},{31,31

2021-02-04 17:13:09 116 1

原创 求根到叶子结点数字之和

求根到叶子结点数字之和题目描述:给定一个二叉树,它的每个结点都存放一个 0-9 的数字,每条从根到叶子节点的路径都代表一个数字。例如,从根到叶子节点路径 1->2->3 代表数字 123。计算从根到叶子节点生成的所有数字之和。说明: 叶子节点是指没有子节点的节点。示例 1:输入: [1,2,3]1/ 2 3输出: 25解释:从根到叶子节点路径 1->2 代表数字 12.从根到叶子节点路径 1->3 代表数字 13.因此,数字总和 = 12 + 13

2020-09-20 17:01:24 144

原创 【双指针】有序数组的 Two Sum

给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数。函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2。说明:返回的下标值(index1 和 index2)不是从零开始的。你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素。示例:输入: numbers = [2, 7, 11, 15], targ...

2020-03-31 11:37:30 253

原创 27. 移除元素

给定一个数组 nums 和一个值 val,你需要原地移除所有数值等于 val 的元素,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。示例 1:给定 nums = [3,2,2,3], val = 3,函数应该返回新的长度 2, 并且 nums 中的前两个元素均为...

2020-02-20 22:04:30 71

原创 餐厅过滤器

1.包含头文件 #include<algorithm>,然后using namespace std;2.假如你定义的vector变量为vector<Type> num,则如下: sort(num.begin(), num.end(), sortFun); 然后如果是基本类型假如是int,第三个参数可以使用系统自带的less<int>()或者greater<int>(),假如是自定义类型话或者复杂类型就需自己定义比较规则函数sortFun,以下以opencv中的Point2d类型举例:

2020-01-28 10:06:53 214

原创 【c++】char* char*[] char** string

char *s;s="China";为什么char*可以赋值一个字符串呢,是因为字符串本身就是一个地址,它是首地址的地址。char*a[]={"China","Franch","America","German"};[]优先级高于* 所以a先和[]结合,是一个数组,然后数组中每个元素是char*。char*a[]={"China","Franch","America","German...

2020-01-27 22:21:09 142

原创 无重复字符的最长子串

题目:给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。示例 1:输入: “abcabcbb”输出: 3解释: 因为无重复字符的最长子串是 “abc”,所以其长度为 3。示例 2:输入: “bbbbb”输出: 1解释: 因为无重复字符的最长子串是 “b”,所以其长度为 1。示例 3:输入: “pwwkew”输出: 3解释: 因为无重复字符的最长子串是 “wk...

2020-01-22 11:56:28 85

转载 01.17G

01.17GGiven a sequence a[1],a[2],a[3]…a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.InputThe ...

2019-01-29 23:22:22 172

转载 01.17F

01.17f给定K个整数的序列{ N1, N2, …, NK },其任意连续子序列可表示为{ Ni, Ni+1, …,Nj },其中 1 &lt;= i &lt;= j &lt;= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和为20。在今年的数据结构考卷中,要...

2019-01-29 23:19:50 144

转载 01.17E

01.17Edp问题现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最大报销额。Input测试输入包含若干测试用例。每个测试用例的第1行包含两个正数 Q 和 N,其中 Q 是给定的报销额度,...

2019-01-29 23:18:03 187

转载 01.17D

01.17DThe end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each o...

2019-01-29 23:05:11 130

原创 01.17C

01.17CIt seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.Now you are suggested to solve t...

2019-01-29 23:02:22 201

原创 01.17B

01.17BA guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, h...

2019-01-29 23:01:13 138

原创 01.17A

01.17ADuring the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the bo...

2019-01-29 22:59:28 134

原创 01.21C

Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes o...

2019-01-22 23:11:44 101

原创 01.21B

Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange...

2019-01-22 23:10:23 160

原创 01.21A

Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them a...

2019-01-22 23:08:14 80

原创 01.22C

Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn’t need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a “plus”) and negative ...

2019-01-22 22:58:26 2109

原创 01.22B

Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could ma...

2019-01-22 22:44:43 166

原创 01.22A

An elephant decided to visit his friend. It turned out that the elephant’s house is located at point 0 and his friend’s house is located at point x(x &gt; 0) of the coordinate line. In one step the el...

2019-01-22 22:41:44 136

原创 A-1

B. Queue at the SchoolDuring the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, afte...

2019-01-18 07:17:29 131

原创 第三次周赛H - Problem H HDU - 2504

H - Problem H HDU - 2504有三个正整数a,b,c(0&lt;a,b,c&lt;10^6),其中c不等于b。若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c。Input第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。Output输出对应的c,每组测试数据占一行。Sample Input26 212 4Sample O...

2018-12-28 09:40:02 158

原创 第三次周赛A - Problem A CodeForces - 439A

Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to “All World Classical Singing Festival”. Other than Devu, comedian Churu was also invited....

2018-12-22 22:06:07 124

原创 第三次周赛B - Problem B CodeForces - 492A

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3...

2018-12-22 22:03:44 107

原创 第三次周赛C - Problem C CodeForces - 822A

Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It’s well known that universities provide stud...

2018-12-22 21:52:27 166

原创 第三次周赛D - Problem D CodeForces - 369A

Valera is a lazy student. He has m clean bowls and k clean plates.Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat...

2018-12-22 21:44:04 234

原创 12.14Y - Nearly Lucky Number

在这里插入代码片#include using namespace std;int main(){long long x; int a[100];cin &amp;gt;&amp;gt; x;int i = 0;int j = 0;while (x){ a[i] = x % 10; i++; x = x / 10;} for(int k=0;k&amp;lt;i;k++) if (a[k]...

2018-12-14 22:10:11 112

原创 第一周周赛D - Problem D HDU - 2039

D - Problem D HDU - 2039给定三条边,请你判断一下能不能组成一个三角形。Input输入数据第一行包含一个数M,接下有M行,每行一个实例,包含三个正数A,B,C。其中A,B,C &amp;lt;1000;Output对于每个测试实例,如果三条边长A,B,C能组成三角形的话,输出YES,否则NO。Sample Input21 2 32 2 2Sample Output...

2018-12-10 18:15:18 138

原创 12.07A. George and Accommodation

A. George and Accommodationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGeorge has recently entered the BSUCP (Berland State University for...

2018-12-10 08:39:38 146

原创 12.07A + B Problem

A + B ProblemCalculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1Sample Output2问题链接:https:/...

2018-12-10 08:39:25 80

原创 12.07A + B Problem Too

A + B Problem TooThis problem is also a A + B problem,but it has a little difference,you should determine does (a+b) could be divided with 86.For example ,if (A+B)=98,you should output no for result....

2018-12-10 08:39:12 87

原创 12.07Stones on the Table

Stones on the TableThere are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had d...

2018-12-10 08:38:34 114

原创 第一次周赛 A - Problem A

A - Problem AOne hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scal...

2018-12-09 14:38:09 129

空空如也

空空如也

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

TA关注的人

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