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 AB, AC and BC. DE 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

    题解:注意面积比是变长比的平方,另外p+1代表s/s2;s代表总面积,s2代表下面的四边形面积

    代码:

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<vector>
    #include<map>
    #include<algorithm>
    using namespace std;
    #define mem(x,y) memset(x,y,sizeof(x))
    #define SI(x) scanf("%d",&x)
    #define SL(x) scanf("%lld",&x)
    #define PI(x) printf("%d",x)
    #define PL(x) printf("%lld",x)
    #define P_ printf(" ")
    #define T_T while(T--)
    typedef long long LL;
    const int INF=0x3f3f3f3f;
    
    int main(){
    	int kase=0;
    	double a,b,c,p;
    	double d,area,ans;
    	int T;
    	SI(T);
    	T_T{
    		scanf("%lf%lf%lf%lf",&a,&b,&c,&p);
    		double k=p+1.0;
    		p=sqrt(1.0-1/k);
    		printf("Case %d: %lf
    ",++kase,a*p);
    	}
    	return 0;
    }
    

      

  • 相关阅读:

    JVM基础
    rpm、yum、解压缩安装
    Vim使用及账号用户管理
    linux常用操作
    属主权限和属组权限
    解决Hystrix Dashboard 一直是Loading ...的情况
    扫描不到了@FeignClient注解的调用接口
    springcloud与springboot版本问题
    【力扣】6和9组成的最大数字 题解
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5023611.html
Copyright © 2011-2022 走看看