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日 动态规划一 ...
随机推荐
- vim 插件之 surround.vim
surround.vim-这个插件主要是用来插入一些特殊符号的(成对出现) 下载地址 http://www.vim.org/scripts/script.php?script_id=1697 http ...
- [BZOJ4026]dC Loves Number Theory 欧拉函数+线段树
链接 题意:给定长度为 \(n\) 的序列 A,每次求区间 \([l,r]\) 的乘积的欧拉函数 题解 考虑离线怎么搞,将询问按右端点排序,然后按顺序扫这个序列 对于每个 \(A_i\) ,枚举它的质 ...
- Aix下查看内存命令
1. 查看物理内存配置 # lsdev -Cc memory 查看配置的物理内存设备,下面为其输出示例: L2cache0 Available L2 Cache mem0 Available ...
- SP1026 FAVDICE - Favorite Dice 数学期望
题目描述: 一个n面的骰子,求期望掷几次能使得每一面都被掷到. 题解:先谈一下期望DP. 一般地,如果终止状态固定,我们都会选择逆序计算. 很多题目如果顺序计算会出现有分母为 0 的情况,而逆序计算中 ...
- scrollWidth到底是什么???
贴上MDN对scrollwidth的定义: The Element.scrollWidth read-only property is a measurement of the width of an ...
- 编程里的API是什么意思?
API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力,而又无需访问源码 ...
- 树莓派3b+ wifi无线连接
一.配置文件启动wifi 配置 /etc/network/interfaces 文件实现,但在图形界面上并没有wifi图标可以选择,这种方法不够灵活,后面连接其它的wifi都要去修改配置文件 首先打开 ...
- cogs 184. [USACO Oct08] 搭建篱笆
184. [USACO Oct08] 搭建篱笆 ★★ 输入文件:quad.in 输出文件:quad.out 简单对比时间限制:1 s 内存限制:128 MB 勤奋的农夫约翰想要修建一个 ...
- Project Euler :Problem 54 Poker hands
In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the ...
- Android资源推荐
Intellj IDEA 安装配置 使用IntelliJ IDEA 13搭建Android集成开发环境(图文教程) Android设计指南站点 图标 App Icon Template免费的Photo ...