Problem C: Longest Common Subsequence Sequence 1: Sequence 2: Given two sequences of characters, print the length of the longest common subsequence of both sequences. For example, the longest common subsequence of the following two sequences: abcdgh…
This is the classic LCS problem. Since it only requires you to print the maximum length, the code can be optimized to use only O(m) space (see here). My accepted code is as follows. #include <iostream> #include <string> #include <vector>…
思路:海伦公式, AC代码: #include<bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); double ha, hb, hc, a, b, c; while(~scanf("%lf %lf %lf",&ha,&hb,&hc)) { a = 2.0 / ha; b = 2.0 / hb ; c = 2.0 / hc; if(…
题意:如题,用表达式树来表示一个表达式,且消除公共的部分,即用编号表示.编号 K 定义为表达式第 K 个出现的字符串. 解法:先构造表达式树,给每棵子树用(string,left_son,right_son)-->(哈希值,...,...)编号.由于最多出现4个小写字母,所以可以用27进制数表示,同时也要利用好映射map的count(),和对应的dict[]的编号. 再递归输出表达式,利用编号的定义,看输出编号或字符串. 注意--这里的自定义比较器用的是"显式定义",若是2个键值…
Tell me the area Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1876 Accepted Submission(s): 567 Problem Description There are two circles in the plane (shown in the below picture), ther…
http://acm.hdu.edu.cn/showproblem.php?pid=1798 Problem Description There are two circles in the plane (shown in the below picture), there is a common area between the two circles. The problem is easy that you just tell me the common area. Input…
题目链接 Problem Description There are two circles in the plane (shown in the below picture), there is a common area between the two circles. The problem is easy that you just tell me the common area. Input There are many cases. In each case, there…