zoukankan      html  css  js  c++  java
  • 二分--1043

    1043 - Triangle Partitioning
    Time Limit: 0.5 second(s) Memory Limit: 32 MB

    See the picture below.

    You are given ABAC and BCDE is parallel to BC. You are also given the area ratio between ADE and BDEC. You have to find the value of AD.

    Input

    Input starts with an integer T (≤ 25), denoting the number of test cases.

    Each case begins with four real numbers denoting AB, AC, BC and the ratio of ADE and BDEC (ADE / BDEC). You can safely assume that the given triangle is a valid triangle with positive area.

    Output

    For each case of input you have to print the case number and AD. Errors less than 10-6 will be ignored.

    Sample Input

    Output for Sample Input

    4

    100 100 100 2

    10 12 14 1

    7 8 9 10

    8.134 9.098 7.123 5.10

    Case 1: 81.6496580

    Case 2: 7.07106781

    Case 3: 6.6742381247

    Case 4: 7.437454786


    PROBLEM SETTER: JANE ALAM JAN



    题目大意很明显,求AD 

    思路:对AD二分  注意边和面积是平方的倍数关系(S=sqrt(p(p-a)(p-b)(p-c)) p=(a+b+c)/2 就能看出来了)

    当然这题也可以找关系直接做出来






    #include<stdio.h>
    #include<math.h>
    #define eps 1e-9
    #define min(a,b) ((a)<(b)?(a):(b))
    int main(){
    	int t;
    	double a,b,c,high,low,mid;
    	scanf("%d",&t); double kk;
    //	cout<<min(t,a);
    	for(int i=1;i<=t;i++){
    		scanf("%lf%lf%lf%lf",&a,&b,&c,&kk);
    		 high=a;
    		 low=0;
    
    		while(high-low>eps){
    			mid=(high+low)/2;
    			if((mid/a)*(mid/a)>kk/(1+kk))  //找对关系式
    				high=mid;
    			else low=mid;
    		}
    		printf("Case %d: %.8lf
    ",i,mid);
    	}
    	return 0;
    }
    


    版权声明:本文为博主原创文章,未经博主允许不得转载。

    today lazy . tomorrow die .
  • 相关阅读:
    在终端聊天
    Vue双向数据绑定的原理
    手动封装on,emit,off
    浅谈Vue中组件传值的几种方式
    常见的一些性能优化的小方法
    常见的一些JS兼容问题
    移动布局的方法
    移动布局的方法
    快速、高效的学习vuex
    移动端300ms延迟原因及解决方案
  • 原文地址:https://www.cnblogs.com/france/p/4808685.html
Copyright © 2011-2022 走看看