题目链接:http://lightoj.com/volume_showproblem.php?

problem=1043

题意:一个三角形ABC,DE//BC。已知三角形ADE和四边形BDEC的面积的比,求AD的长度。

解法:二分AD边就可以

代码:

#include <stdio.h>
#include <ctime>
#include <math.h>
#include <limits.h>
#include <complex>
#include <string>
#include <functional>
#include <iterator>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <assert.h> using namespace std; int main()
{
int t; int cases = 1; double a, b, c, ratio;
scanf("%d",&t);
while (t--)
{
cin >> a >> b >> c >> ratio; double s = a*b;
double ans; ratio = ratio / (ratio + 1.0); double left = 0, right = a;
double mid; while (left + 0.000000001<= right)
{
mid = (left + right) / 2.0;
ans = mid * b * (mid / a);
ans /= s; if (ans >= ratio) right = mid;
else left = mid;
} printf("Case %d: ", cases++);
printf("%.9lf\n", right);
}
return 0;
}

Lightoj 1043 - Triangle Partitioning【二分】的更多相关文章

  1. 二分--1043 - Triangle Partitioning

    1043 - Triangle Partitioning PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit:  ...

  2. 1043 - Triangle Partitioning(数学)

    1043 - Triangle Partitioning   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit ...

  3. Lightoj 1044 - Palindrome Partitioning (DP)

    题目链接: Lightoj  1044 - Palindrome Partitioning 题目描述: 给一个字符串,问至少分割多少次?分割出来的子串都是回文串. 解题思路: 先把给定串的所有子串是不 ...

  4. lightoj.1048.Conquering Keokradong(二分 + 贪心)

    Conquering Keokradong Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

  5. LightOJ 1044 Palindrome Partitioning(简单字符串DP)

    A palindrome partition is the partitioning of a string such that each separate substring is a palind ...

  6. lightoj 1044 - Palindrome Partitioning(需要优化的区间dp)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1044 题意:求给出的字符串最少能分成多少串回文串. 一般会想到用区间dp暴力3个for ...

  7. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  8. lightoj--1043-- Triangle Partitioning (水题)

    Triangle Partitioning Time Limit: 500MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu S ...

  9. 【转载】ACM总结——dp专辑

    感谢博主——      http://blog.csdn.net/cc_again?viewmode=list       ----------  Accagain  2014年5月15日 动态规划一 ...

随机推荐

  1. 20.发送http请求服务 ($http)

    转自:https://www.cnblogs.com/best/tag/Angular/ 服务从代码直接与服务器进行交互,底层是通过实现,与中http服务从AngularJS代码直接与Web服务器进行 ...

  2. cf 864 F. Cities Excursions

    F. Cities Excursions There are n cities in Berland. Some pairs of them are connected with m directed ...

  3. 开源系统源码分析(filter.class.php)

    <?php class baseValidater { //最大参数个数 const MAX_ARGS=3; public static function checkBool($var) { r ...

  4. Vue 项目搭建 与 git 连接

    整理一下::::: git 方面: -----------注册------登录--------就不用写了 这里使用的是码云: 1. 进入个人中心添加项目. 2.添加完项目添加SSH公钥.(在设置里面) ...

  5. USB摄像头驱动框架分析(五)

    一.USB摄像头驱动框架如下所示:1.构造一个usb_driver2.设置   probe:        2.1. 分配video_device:video_device_alloc        ...

  6. PHP抓取网页内容的几种方法

    方法1: 用file_get_contents 以get方式获取内容 <?php $url='http://www.domain.com/?para=123'; $html = file_get ...

  7. web开发快速提高工作效率的一些资源

    前端学习资源实在是又多又广,在这样的一个知识的海洋里,我们像一块海绵一样吸收,想要快速提高效率,平时的总结不可缺少,以下总结了一些,排版自我感觉良好,推送出来,后续持续跟新中...... 开发工具 H ...

  8. LinkedHashMap<String, Bitmap>(0, 0.75f, true) LinkedHashMap的加载因子和初始容量分配

    今天上午在CSDN的论坛里看到有朋友提的问题如下: /** @param maxSize Maximum sum of the sizes of the Bitmaps in this cache * ...

  9. 5.brackets 快捷键 有大用

    转自:https://blog.csdn.net/u012011360/article/details/41209223 ctrl+b 当选中一个文本时,会出现相同的文本,被高亮显示 按ctrl+b ...

  10. POJ 3168 排序+扫描

    题意: 思路: 我们可以把每个矩形拆成四条线 与x轴平行的放在一起 与y轴平行的放在一起 排个序 判一判有没有交 有交 则说明不可扩张 统计一下 就可以了 处理的姿势很重要 姿势不对毁一生 //By ...