暴力。 虽然$a[i]$最大有${10^9}$,但是$m$最大只有${10^6}$,因此可以考虑暴力。 记$cnt[i]$表示数字$i$有$cnt[i]$个,记$p[i]$表示以$i$为倍数的情况下,最多能选出多少个数字。 $p[i]$可以暴力计算出来,最后就是找到$p[i]$最大的$i$,然后输出 ...
分类:
其他好文 时间:
2016-09-28 22:34:09
阅读次数:
146
[http://poj.org/problem?id=3764] (题目链接) 今天的考试题,看到异或就有点虚,根本没往正解上想。。 题意:给出一棵带权树,请找出树上的一条路径,使其边上权值的异或和最大。 solution 首先我们考虑从根向下dfs,记录下每个点i到根上权值的异或和val[i]。根 ...
分类:
其他好文 时间:
2016-09-28 15:53:07
阅读次数:
166
本问题是求最长不重复子串。 给出一种方法: 例如:aplsdfgsjiuk,设置一个最长子串的起始位和结束位,a为起始位,b为结束位,当遍历aplsdfg时,下一位s重复,所以可以从d为起始位置在遍历。 时间复杂度为O(n)。 ...
分类:
其他好文 时间:
2016-09-27 11:29:14
阅读次数:
95
找到提供的句子中最长的单词,并计算它的长度。 函数的返回值应该是一个数字。 ...
分类:
其他好文 时间:
2016-09-26 17:41:25
阅读次数:
97
题目来自 https://leetcode.com/problems/longest-palindromic-substring/ 题目:Given a string S, find the longest palindromic substring in S. You may assume tha ...
分类:
其他好文 时间:
2016-09-25 17:26:09
阅读次数:
149
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng ...
分类:
其他好文 时间:
2016-09-24 23:20:25
阅读次数:
137
Verrazano, an Italian about whom little is known, sailed into New York Harbour in 1524 and named it Angouleme. He described it as 'a very agreeable si ...
分类:
其他好文 时间:
2016-09-24 13:26:29
阅读次数:
114
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longes ...
分类:
其他好文 时间:
2016-09-24 11:54:09
阅读次数:
132
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo ...
分类:
其他好文 时间:
2016-09-24 07:01:04
阅读次数:
144