矩形神码的
Time Limit: 1000ms
Memory Limit: 65536KB
64-bit integer IO format:
%lld Java class name:
Main
Special Judge
Prev
Submit
Status
Statistics
Discuss
Next
我们都知道,矩形是由两条对角线的,没错吧?(谜之声:这不是显然么!)这两条线的长度也是相等的,没错吧?(谜之声:这不废话么!)然后我们给定一条对角线的起始点和终止点的坐标,然后给定另一个对角线和他的夹角,是不是就能得到两个面积相等的矩形?(谜之声:呃,貌似好像或许应该可能maybe perhaps probably possibly是对的?)
现在我需要你求出这个矩形的面积。
Input
第一行,一个整数T(0<T<=10000),表示数据组数。
接下来T行,每行5个浮点数。分别是x1,y1,x2,y2,theta。表示一条对角线的起始点和终止点的坐标,以及另一条对角线与他的夹角。坐标的绝对值范围均在10
4以内,夹角范围(0,90]。
Output
对于每一组数据,输出一行,表示面积,精确到小数点后六位。
绝对误差或者相对误差在0.0001内均算通过。
Sample Input
2
1.0 1.0 -1.0 -1.0 90.0
3.0 2.0 2.5 9.99 36.00
Sample Output
4.000000
18.835608
Hint
pi请取值acos(-1.0)或者3.1415926535898
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define pi 3.1415926535898
using namespace std;
int main()
{
double x1,y1,x2,y2;
double t;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&t);
double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))/2;
double a=t/180*pi;
double b=pi-a;
double s=d*d*sin(a)+d*d*sin(b);//三角形面积公式1/2bcsina
printf("%.6lf\n",s);
}
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-1288225.html