HDU 2552 三足鼎立(数学函数)

/*
<耶律javac++>欲找出三人所在逐个击破,
现在他发现威士忌的位置s,天外来客的位置u,
不过很难探查到亦纷菲v所在何处,只能知道三人满足关系:
arctan(1/s) = arctan(1/u)+arctan(1/v)
注:(其中0 <= x <= 1)
定义 f(s, u, v) = v*u-s*u-s*v 的值 为<三足鼎立>
<耶律javac++>想计算<三足鼎立>的值
*/
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int t;
    double s,u,v;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf",&s,&u);
        v=1.0/tan(atan(1/s)-atan(1/u));//注意运用函数
        printf("%.0f
",(v*u-s*u-s*v));
    }

}

  

原文地址:https://www.cnblogs.com/Roni-i/p/7207779.html