转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2876
HDU集训队选拔赛地点:3教3楼机房,时间:5月10日(周六)12:00開始,请相互转告,谢谢~ |
Ellipse, again and againTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 537 Accepted Submission(s): 200 Problem Description There is an ellipse in the plane, its formula Input The first line contains a positive integer n that Output For each test case, output one line. If the given Sample Input
Sample Output
Source 2009 Multi-University Training Contest 8 - Host by Recommend gaojie |
求距离!
#include <stdio.h>
#include <math.h>
int main()
{
double xQ,yQ;
double k1;
int a,b,x0,y0,T;
while(~scanf("%d",&T))//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
{
while(T--)//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
{
scanf("%d%d%d%d",&a,&b,&x0,&y0);
k1=y0/(x0*1.0);//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
xQ=sqrt((a*a*b*b*1.0)/(a*a*k1*k1+b*b));//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
yQ=k1*xQ;int flag= 0;//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
int w=a*a-b*b;//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
if((x0*x0)/(a*a)+(y0*y0)/(b*b)<1)//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
{
printf("In ellipse\n");//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
continue;
}
if(w < 0)//标记焦点所在轴
{
flag =1;
w=-w;
}
double F1,F2;//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
double c =sqrt(w*1.0);//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
if(flag == 0)
{
F1 = sqrt((xQ+c)*(xQ+c)+(yQ*yQ));//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
F2 = sqrt((xQ-c)*(xQ-c)+yQ*yQ);//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
}
else
{
F1 = sqrt(xQ*xQ+(yQ+c)*(yQ+c));//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
F2 = sqrt(xQ*xQ+(yQ-c)*(yQ-c));//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
}
double t = (sqrt)((xQ*xQ*b*b*b*b)*1.0+(yQ*yQ*a*a*a*a)*1.0);//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
double d =a*a*b*b/(t*1.0);
double D=d*d*F1*F2;//化简后D==a*a*b*b FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
D = a*a*b*b;
printf("%.0lf\n",D);
}
}
return 0;
}
以下给出证明:
至此D=d*d*F1*F2可化简为D=a*a*b*b
所以给出简短代码:
#include<cstdio>
int main()
{
int a,b,x0,y0;
int T;
while(~scanf("%d",&T))
{
while(T--)
{
scanf("%d%d%d%d",&a,&b,&x0,&y0);
if(x0*x0/(a*a)+y0*y0/(b*b)<1)
printf("In ellipse\n");
else
printf("%d\n",a*a*b*b);
}
}
return 0;
}
HDU 2876 Ellipse, again and again,布布扣,bubuko.com