题意: 青蛙 A 和 青蛙 B ,在同一纬度按照相同方向跳跃相同步数,A的起点为X ,每一步距离为m,B的起点为Y,每一步距离为 n,一圈的长度为L,求最小跳跃步数. 思路: 一开始按照追击问题来写,结果发现会求出来小数,而且按照追击问题写的话,一圈就能相遇,但是!青蛙的步数可没有小数,而且青蛙是跳跃的,显然不能在空中相遇吧. 所以咧,先列出一个追击的式子 ,设步数为 t ,整数为K(转了K圈以后他们才到同一个地方) t * m + x = t * n + y + k * L ===> t *…
寻找包裹轮廓的最小正矩形:boundingRect 函数 返回矩阵应满足:① 轮廓上的点均在矩阵空间内.② 矩阵是正矩阵(矩形的边界与图像边界平行). Rect boundingRect(InputArray points); 唯一一个参数是输入的二维点集,可以是 vector 或 Mat 类型. 代码示例: #include<opencv.hpp> #include<iostream> using namespace cv; using namespace std; int ma…
题目链接:51nod 1065 最小正子段和 房教说用前缀和做,然后看了别人博客懂了后就感觉,这个真有意思... #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; const int inf = 0x3f3f3f3f; pair<long long, int> sum[N]; int a[N]; int n; int main(){ int i, j;…
有两个序列A和B,A=(a1,a2,...,ak),B=(b1,b2,...,bk),A和B都按升序排列.对于1<=i,j<=k,求k个最小的(ai+bj).要求算法尽量高效. int *min_k(int *A, int *B, int len1, int len2, int k) { if (A == NULL || B == NULL || k <= 0) return NULL; int i, j; int *tmp = new int[k]; i = len1; j = len…
hdu3746 Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2262 Accepted Submission(s): 1005 Problem Description CC always becomes very depressed at the end of this month, he ha…
Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple of L and consist of…