Lightoj 1043 - Triangle Partitioning【二分】
题目链接: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【二分】的更多相关文章
- 二分--1043 - Triangle Partitioning
1043 - Triangle Partitioning PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: ...
- 1043 - Triangle Partitioning(数学)
1043 - Triangle Partitioning PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit ...
- Lightoj 1044 - Palindrome Partitioning (DP)
题目链接: Lightoj 1044 - Palindrome Partitioning 题目描述: 给一个字符串,问至少分割多少次?分割出来的子串都是回文串. 解题思路: 先把给定串的所有子串是不 ...
- lightoj.1048.Conquering Keokradong(二分 + 贪心)
Conquering Keokradong Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- LightOJ 1044 Palindrome Partitioning(简单字符串DP)
A palindrome partition is the partitioning of a string such that each separate substring is a palind ...
- lightoj 1044 - Palindrome Partitioning(需要优化的区间dp)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1044 题意:求给出的字符串最少能分成多少串回文串. 一般会想到用区间dp暴力3个for ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- lightoj--1043-- Triangle Partitioning (水题)
Triangle Partitioning Time Limit: 500MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu S ...
- 【转载】ACM总结——dp专辑
感谢博主—— http://blog.csdn.net/cc_again?viewmode=list ---------- Accagain 2014年5月15日 动态规划一 ...
随机推荐
- vue16 自定义键盘属性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 分析一下jquery中的ajax操作
在web前端开发中,ajax是很重要的一项技术,用原生写起来很是麻烦,需要一大堆js代码,而到了jq里就被精简了许多,一起来看看: jquery中的ajax分为三种方式: 1.$.get(),get方 ...
- 线性同余同余方程组解法(excrt)
[问题描述] 求关于 x 的同余方程组 x%a 1 =b 1 a1=b1 x%a 2 =b 2 a2=b2 x%a 3 =b 3 a3=b3 x%a 4 =b 4 a4=b4 的大于等于 0 ...
- datatable设置成中文
$('#datatable').DataTable({ language: { "sProcessing": "处理中...", "sLengthMe ...
- Linux PuTTY 更改字体
Linux PuTTY默认的字体比较小看着比较不舒服,Linux PuTTY的字体更改与Windows下的设置有所不同 1.Linux PuTTY默认的字体 ,Font used for ordina ...
- <QT障碍之路>qt中使用串口类接收数据不完整
问题:当用QT中的serial->readAll()的时候,不会把全部的数据一次性都读取出来,而是阶段性的.原因是因为当串口有信号时候,readyRead()信号就会被抛出,那么一帧完整的数据帧 ...
- SpringBoot常用注解的介绍及使用 - 转载
常用注解 @springBootApplication 系统启动类注解,此注解是个组合注解,包括了:@SpringBootConfiguration,@EnableAutoConfiguration, ...
- <LeetCode OJ> 20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...
- 【Android】各式各样的弹出框与对菜单键、返回键的监听
Android自带各式各样的弹出框.弹出框也是安卓主要的组件之中的一个.同一时候安卓程序能够对菜单键.返回键的监听.但在安卓4.0之后就禁止对Home键的屏蔽与监听,强制保留为系统守护按键.假设非要对 ...
- leetCode 27.Remove Element (删除元素) 解题思路和方法
Remove Element Given an array and a value, remove all instances of that value in place and return th ...