Catenyms Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8756 Accepted: 2306 Description A catenym is a pair of words separated by a period such that the last letter of the first word is the same as the last letter of the second. For e
Description A substring of a string T is defined as: T( i, k)= TiTi+1... Ti+k-1, 1≤ i≤ i+k-1≤| T|. Given two strings A, B and one integer K, we define S, a set of triples (i, j, k): S = {( i, j, k) | k≥ K, A( i, k)= B( j, k)}. You are to give the val
In the math class, the evil teacher gave you one unprecedented problem! Here f(n) is the n-th fibonacci number (n >= 0)! Where f(0) = f(1) = 1 and for any n > 1, f(n) = f(n - 1) + f(n - 2). For example, f(2) = 2, f(3) = 3, f(4) = 5 ... The teacher u
求最短路的算法最有名的是Dijkstra.所以一般拿到题目第一反应就是使用Dijkstra算法.但是此题要求的好几对起点和终点的最短路径.所以用Floyd是最好的选择.因为其他三种最短路的算法都是单源的. 输出字典序最小的路径则需要修改模版. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; , INF=; int Ma
题目链接:http://poj.org/problem?id=1815 In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can assume that people A can keep in touch with people B, only if 1. A kno
//LCS模板,求长度,并记录子串 //亦可使用注释掉的那些代码,但所用空间会变大 #include<iostream> #include<cstring> #include<cmath> #include<cstdlib> #include<cstdio> using namespace std; #define N 5005 int len[N][N]; char str1[N],str2[N],str3[N]; int k; int lc