uva 10566 Crossed Ladders (二分)】的更多相关文章

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1507 比较简单的一题,直接对答案二分.因为对于同一组case,答案m越大,交点的高度就越小,可以从计算交点的函数中看出来.计算交点,假设mx=sqrt(sqr(x)-sqr(m)),my=sqrt(sqr(y)-sqr(m)),这两个是梯子跟两堵墙的交点.那么,交点的高度就是mx*my/(m…
题目链接:uva 1335 - Beijing Guards 题目大意:有n个人为成一个圈,其中第i个人想要r[i]种不同的礼物,相邻的两个人可以聊天,炫耀自己的礼物.如果两个相邻的人拥有同一种礼物,则双方都会很不高兴,问最少需要多少种不同的礼物才能满足所有人的需求,假设每种礼物有无限多个. 解题思路:自己想没有什么思路,参照大白书上的解释,琢磨了一下. 如果n为偶数的话,ans = max{r[i] + r[i + 1] },(r[n + 1] = r[1]). 如果n为奇数的话,上述式子就不…
Problem  UVA - 11478 - Halum Time Limit: 3000 mSec Problem Description You are given a directed graph G(V,E) with a set of vertices and edges. Each edge (i,j) that connects some vertex i to vertex j has an integer cost associated with that edge. Defin…
求使最大值最小,可以想到二分答案. 然后再根据题目意思乱搞一下,按要求输出斜杠(这道题觉得就这一个地方难). Code /** * UVa * Problem#12627 * Accepted * Time:0ms */ #include<iostream> #include<cstdio> #include<cctype> #include<ctime> #include<cstring> #include<cstdlib> #in…
题目大意:给6个系数,问是否存在X使得等式成立 思路:二分.... #include <stdio.h> #include <math.h> #define EEE 2.71828182845953581496 int p, q, r, s, t, u; double v(double x) { return (p*pow(EEE,-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x); } double f(double x,double z, double…
利用height值对后缀进行分组的方法很常用,好吧,那就先记下了. 题意: 给出n个字符串,求一个长度最大的字符串使得它在超过一半的字符串中出现. 多解的话,按字典序输出全部解. 分析: 在所有输入的字符串后面加一个原串中没有的且互不相同的字符,然后将新得到的n个字符串拼接成一个长的字符串.(为什么要加互不相同的分割字符,这里始终想不明白) 首先二分最大公共字串的长度p.扫描一遍height数组,每遇到一个height[i] < p便开辟一个新段,这样就将height数组拆分为若干段.而且每一段…
题目链接: 题目 Copying Books Time limit: 3.000 seconds 问题描述 Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a book and after s…
题意: 给出一个整数n,如果n是素数输出0,否则输出它后一个素数与前一个素数的差值. 分析: 首先用筛法把前十万个素数都筛出来,然后放到数组里.用二分找到不大于n的最大的素数的下标,如果这个素数等于n,则直接输出0,否则输出它后一个素数与它本身的差值. #include <cstdio> #include <cmath> ; ; ]; ], cnt = ; void Init() { int m = sqrt(maxn + 0.5); ; i <= m; ++i) if(!v…
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2255 题意 n个任务,允许时间区间为[ri, di](ri , di <= 20000),运算量为wi,可以分割,问最小运算速度 思路 明显,应该二分枚举最小运算速度, 对于时刻i来说,应该优先处理已经开始的最早结束的任务.接着,如果任务已经处理完毕,那就应该等待…
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2683 题意 原来有1个,每次可以任选数量成倍增长,问要操作多少次到n 思路 明显,先扩增到最大数位maxDigit,比如10,先扩增到8,然后再选择n - maxDigit扩增即可.因而结果为log2(n) 代码 #include <algorithm> #include…