题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo....
分类:
编程语言 时间:
2014-08-04 04:10:26
阅读次数:
374
HDU 4002 Find the maximum(数论-欧拉函数)
题目大意:
给定一个n,问你1~n中,求一个数 x 使得 x/φ(x) 的值最大。
解题思路:
根据欧拉函数的公式,φ(x)=x(1-1/p1)(1-1/p2)(1-1/p3)(1-1/p4)…..(1-1/pn)
则:x/φ(x)=p1/(p1-1)*p2/(p2-1)*......*pn/(pn-1)
可以看出项越多x/φ(x)越大,且因子越小x/φ(x)越大,那么只需要2*3*5*7....
考虑到数字很大,所以用JAVA来写...
分类:
其他好文 时间:
2014-08-03 23:16:46
阅读次数:
268
本题的题意理解之后,就是求最长回文子序列 longest palindrome subsequence,这里注意子序列和子串的区别。
有两种求法,一种是直接求,相当于填矩阵右上对角阵,另一种是转化为longest common subsequence的求法。
最大难点就是要求内存不能使用二维的。 故此第一种方法是有点难度的,因为需要把二维矩阵的对角线转化为一维表记录,对好下标就好了。
第二中...
分类:
其他好文 时间:
2014-08-02 23:32:34
阅读次数:
326
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
/**
* Definition for binary tree
...
分类:
其他好文 时间:
2014-08-02 23:32:04
阅读次数:
232
有一个正整数序列,求最短的子序列使得其和大于等于S,并输出最短的长度。用数组b[i]存放序列的前i项和,所以b[i]是递增的。遍历终点j,然后在区间[0, j)里二分查找满足b[j]-b[i]≥S的最大的i,时间复杂度为O(nlongn)。这里二分查找用到库函数lower_bound() 1 //#...
分类:
其他好文 时间:
2014-08-02 23:20:54
阅读次数:
269
Delay Constrained Maximum Capacity Path
Time Limit:10000MS Memory Limit:65535KB 64bit IO Format:%I64d
& %I64u
Submit Status
Description
Consider an undirected graph with N vert...
分类:
其他好文 时间:
2014-08-02 18:31:43
阅读次数:
313
解题报告
题目传送门
题意:
有N个点,点1为珍贵矿物的采矿区, 点N为加工厂,有M条双向连通的边连接这些点。走每条边的运输容量为C,运送时间为D。
他们要选择一条从1到N的路径运输, 这条路径的运输总时间要在T之内,在这个前提之下,要让这条路径的运输容量尽可能地大。
一条路径的运输容量取决与这条路径中的运输容量最小的那条边。
思路:
二分容量建图,spfa判时间是否符合...
分类:
其他好文 时间:
2014-08-02 18:31:13
阅读次数:
375
题目链接:点击打开链接
#include
#include
#include
using namespace std;
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
typedef long long ll;
int main()
{
int i, j;
double m,n;
while...
分类:
其他好文 时间:
2014-08-02 18:20:43
阅读次数:
233
问题:最大连续子窜和是多少分析:动态规划,定义max记录最大值,sum记录以i结束的连续子窜的最大值class Solution {public: int maxSubArray(int A[], int n) { int sum; int MAX=A[0]; ...
分类:
其他好文 时间:
2014-08-02 17:55:23
阅读次数:
191
输入n、m,表示一个n面的色子(面上的值为1-n),投掷m次,求得到的最大值的期望(1?≤?m,?n?≤?105)....
分类:
其他好文 时间:
2014-08-02 12:57:13
阅读次数:
189