码迷,mamicode.com
首页 >  
搜索关键字:hdu 二分查找    ( 33808个结果
hdu 3081 Marriage Match II(最大流 + 二分 + 并查集)
Marriage Match II                                                                           Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Descript...
分类:其他好文   时间:2014-05-26 04:40:15    阅读次数:228
HDU4430:Yukari's Birthday(二分)
Problem Description Today is Yukari's n-th birthday. Ran and Chen hold a celebration party for her. Now comes the most important part, birthday cake! But it's a big challenge for them to place n ca...
分类:其他好文   时间:2014-05-26 04:38:35    阅读次数:239
任意多边形的重心
http://acm.hdu.edu.cn/showproblem.php?pid=1115思路:转换为求三角形的重心。从第一个顶点出发,分别链接i,i+1形成三角形,分别求出每个三角形的面积,总面积之和为各部分之和。根据物理公式n个点的质量是mi,则重心是:X=(x1*m1+x2*m2+...xn...
分类:其他好文   时间:2014-05-26 04:04:18    阅读次数:232
HDU4033:Regular Polygon(二分+余弦定理)
Problem Description In a 2_D plane, there is a point strictly in a regular polygon with N sides. If you are given the distances between it and N vertexes of the regular polygon, can you calculate t...
分类:其他好文   时间:2014-05-26 03:50:40    阅读次数:252
笔试算法题(30):从已排序数组中确定数字出现的次数 & 最大公共子串和最大公共序列(LCS)
出题:在已经排序的数组中,找出给定数字出现的次数;分析:解法1:由于数组已经排序,所以可以考虑使用二分查找确定给定数字A的第一个出现的位置m和最后一个出现的位置n,最后m-n+1就是A出现的次数;使用二分查找可疑快速确定给定数字,但是如果确定其左右范围则比较麻烦,对编码细节要求较高;解法2:Hash...
分类:其他好文   时间:2014-05-26 02:54:22    阅读次数:1285
二分查找
二分查找也是分治策略和递归一个重要的实例。对于一个有序的数组,二分查找的时间复杂度是O(logn)int binarysearch(int a[],int s,int e,int k){ int mid =(s+e)/2; if(k==a[mid]) return mid;...
分类:其他好文   时间:2014-05-26 02:23:44    阅读次数:170
定积分求面积
http://acm.hdu.edu.cn/showproblem.php?pid=1071#include#includeint main(){ //freopen("in.txt","r",stdin); int t; scanf("%d",&t); while(t--)...
分类:其他好文   时间:2014-05-26 02:14:56    阅读次数:222
线段交点模版
http://acm.hdu.edu.cn/showproblem.php?pid=1086跨立实验算法#include#include#include#includeusing namespace std;struct Point{ double x,y;} ;struct Line{ ...
分类:其他好文   时间:2014-05-26 02:10:52    阅读次数:224
LeetCode:3Sum
题目:         Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique  triplets in the array which gives the sum of zero. Note: Elements...
分类:其他好文   时间:2014-05-25 00:39:37    阅读次数:343
算法——基础篇——二分查找
二分查找又称折半查找,优点是比较次数少,查找速度快,平均性能好;其缺点是要求待查表为有序表,且插入删除困难。因此,折半查找方法适用于不经常变动而查找频繁的有序列表。     首先,假设表中元素是按升序排列,将表中间位置记录的关键字与查找关键字比较,如果两者相等,则查找成功;否则利用中间位置记录将表分成前、后两个子表,如果中间位置记录的关键字大于查找关键字,则进一步查找前一子表,否则进一步查找后一...
分类:其他好文   时间:2014-05-24 17:17:38    阅读次数:237
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!