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

      

  • 相关阅读:
    当tp5项目上传到服务器之后遇见的各种bug(不定期更新)
    解决LAMP下 服务器IP无法访问
    thinkphp5多图上传+同时删除本地文件
    from提交表单后 数据提交到后台 但不跳转页面 非ajax 用iframe
    window7 安装sass和compass
    开源操作系统课程设计
    Hadoop伪分布式搭建实验总结
    排序集合
    快排
    邻接矩阵
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5023611.html
Copyright © 2011-2022 走看看