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;
    }
    

      

  • 相关阅读:
    QuickFlash
    第五课:类的封装性 M
    第六课:构造方法、匿名对象 M
    第四课:面向对象(基础) M
    第八课:引用传递 M
    第七课:String类 M
    第二课:数组 M
    第三课:方法 M
    ASP .Net的应用程序域(The Application Domain)
    js 解数独程序
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5023611.html
Copyright © 2011-2022 走看看