
二分法
tian_he_he
GeeGee
展开
-
hpu暑假训练B - Pie 【二分法】
My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of转载 2017-07-27 11:33:58 · 387 阅读 · 0 评论 -
hpu暑假训练C - Trailing Zeroes (III) 【二分法】&&【思维转化】
You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you knowN! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the转载 2017-07-27 15:56:19 · 300 阅读 · 0 评论 -
二分搜素查找某个值
/* 设 a[0:n-1]是已排好序的数组,请改写二分搜索算法, 使得当搜索元素 x 不在数组中时, 返回小于 x 的最大元素位置 i 和大于 x 的最小元素位置 j。 当搜索元素在数组中时,i 和 j 相同, 均为 x 在数组中的位置。*/#include<cstdio>#include<algorithm>using namespace std;/*...原创 2019-01-06 16:51:38 · 389 阅读 · 1 评论 -
递归与分治--快速排序
#include<cstdio>#include<algorithm>using namespace std;int Partition(int a[], int s, int t) //划分算法{ int i = s, j = t; int tmp = a[s]; //用序列的第1个记录作为基准 while (i != j) //从序列两端交...原创 2019-01-07 11:24:22 · 388 阅读 · 0 评论 -
矩阵连乘问题
/*从连乘矩阵个数为2开始计算每次的最小乘次数为m[i][j]: m[0][1] m[1][2] m[2][3] m[3][4] m[4][5] 其中m[0][1]表示第一个矩阵与第二个矩阵的最小乘次数然后再计算再依次计算连乘矩阵个数为3:m[0][2] m[1][3] m[2][4] m[3][5]连乘矩阵个数为4:m[0][3] m[1][4] m[2][5]连乘矩阵个数为5...原创 2019-01-08 10:44:52 · 416 阅读 · 0 评论 -
重复元素排列问题
/*算法思路 :aacc四个元素的全排列,我们可以划分为3个元素的全排列,3个划分为2个,到最后只剩下1个元素,就不需要排列。我们让每一个元素作为打头元素,交换,然后进行递归,再交换。如果该打头元素在前面中已经有过,则忽略这种情况。*/#include<cstdio>#include<cmath>#include<algorithm>usi...原创 2019-01-08 11:29:55 · 576 阅读 · 0 评论