摘要:
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Example 2: Example 3: 阅读全文
摘要:
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: 阅读全文
摘要:
暴力 动态规划: d[i][j]标识s串i到j是回文串。判断d[i][j],只需满足s[i]=s[j],切d[i][j]=true 阅读全文
摘要:
O(N^2)AC.. 使用hash表优化查询... 阅读全文
摘要:
问题:给出一个n结点的图,求最大边与最小边差值最小的生成树 my code: #include #include #include #include #include #include using namespace std;
#define N 102
#define INF 0x7fffffff struct Edge { int u, v, w; bool op... 阅读全文
摘要:
问题:输入一个结点的无根树的各条边,并指定一个根结点,要求把该树转化为有根树 测试oj:nyoj http://acm.nyist.net/JudgeOnline/problem.php?pid=20 当结点数很多时若用邻接矩阵存储图将占用很大的空间,此时可使用vector或邻接表存储,由于vector内存的增长方式问题也可能会引起内存过大问题,此时邻接表存储更具优势 代码: 使用vector... 阅读全文
摘要:
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=79题意即求最长单调递减子序列#include#include#includeusing namespace std;#define N 22int h[N];int d[N];int mai... 阅读全文
摘要:
题解链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=541 几天前百度题解后用数学知识AC的,后来大牛说这是一道动态规划题。 网上的数学解题链接:http://blog.csdn.net/x314542916/article/details/8 阅读全文
摘要:
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=592 解决以下问题后就方便用广搜解: 1、将数字坐标化,10000坐标为(0,0),这样就可以通过数字获得其坐标 2、通过一个坐标知道在这个位置上的数字是否为素数 #include
#include
#include
#include
#include using namespace... 阅读全文
摘要:
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=202 一棵树左旋或者右旋,树的中序遍历保持不变 #include
#include
#include
using namespace std; int ls[25];
int rs[25]; int n; void print(int id)
{ if(id == -1 ||... 阅读全文