上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 23 下一页
摘要: 题目描述 给定 n 个实数,求这n个实数在数轴上相邻2个数之间的最大差值,设计解最大间隙问题的线性时间算法(时间复杂度为O(n))。 给定 n 个实数,求这n个实数在数轴上相邻2个数之间的最大差值,设计解最大间隙问题的线性时间算法(时间复杂度为O(n))。 输入 第一行一个正整数n(2<=n<=2× 阅读全文
posted @ 2019-09-03 22:33 Osea 阅读(3159) 评论(0) 推荐(0) 编辑
摘要: 图片来源: https://blog.csdn.net/dylan_frank/article/details/78177368 【题意】: 对于每一个节点来说有多少对相同的子树。 【题解】: 利用层数进行hash,返回到对应的节点,最后标记后用等差数列来求出所有方案数。 1 #pragma GCC 阅读全文
posted @ 2019-09-03 21:48 Osea 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Parentheses 题目描述 Dave loves strings consisting only of '(' and ')'. Especially, he is interested in balanced strings. Any balanced strings can be cons 阅读全文
posted @ 2019-09-03 21:36 Osea 阅读(423) 评论(0) 推荐(0) 编辑
摘要: 题目描述 The people of a certain kingdom make a revolution against the bad government of the princess. The revolutionary army invaded the royal palace in 阅读全文
posted @ 2019-09-03 21:22 Osea 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 题目描述 Given a positive integer k, we define a rooted tree to be k-perfect, if and only if it meets both conditions below:•Each node is either a leaf no 阅读全文
posted @ 2019-09-01 09:23 Osea 阅读(455) 评论(0) 推荐(0) 编辑
摘要: 题目描述 正整数 x 的约数是能整除x的正整数,其约数的个数记为div(x),例如div(10)=4。设 a 和 b 是两个正整数,找出 a 和 b 之间(包含a,b)约数个数最多的数 x 的约数个数 输入 两个正整数a和b,(1<=a<=b<=1e5) 输出 一个正整数表示答案。 样例输入 样例输 阅读全文
posted @ 2019-08-31 10:02 Osea 阅读(1317) 评论(0) 推荐(1) 编辑
摘要: 题目描述 在数据加密和数据压缩中常需要对特殊的字符串进行编码。给定的字母表A由26个小写字母组成。该字母表产生的升序字符串中字母从左到右出现的次序与字母在字母表中出现的次序相同,且每个字符最多出现1次。例如,a,b,ab,bc,xyz等字符串都是升序字符串。现在对字母表中产生的所有长度不超过6的升序 阅读全文
posted @ 2019-08-30 22:30 Osea 阅读(1432) 评论(0) 推荐(0) 编辑
摘要: 题目描述 给定一本书,其中包含n页,计算出书的全部页码中用到了多少个数字0…9?页码从1开始 输入 一个整数n,代表页码总数。(1<=n<=1e9) 输出 十行,每行一个整数,分别表示0~9每个数字出现的次数 1 /* 2 数字统计问题 3 */ 4 5 #include<cstdio> 6 #in 阅读全文
posted @ 2019-08-30 22:13 Osea 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 【题意】 这个题目就是问,是否存在每个人对应每一种颜色,如果存在则输出字典序最小的。 否则输出-1 【题解】 利用next_permutation来构造36种情况。记住最后还需要排序一遍。 然后用子序列判断是否存在。while写即可。 1 #include<bits/stdc++.h> 2 usin 阅读全文
posted @ 2019-08-30 22:06 Osea 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int sublater(char *s){ 4 int i,j,k,t; 5 int n=strlen(s); 6 printf("###\n"); 7 for( i=0 , j=1 ; j<n 阅读全文
posted @ 2019-08-27 11:29 Osea 阅读(184) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 23 下一页