HDU 2876 Ellipse, again and again(数学题)
来源:互联网 发布:中国历年gdp增速数据 编辑:程序博客网 时间:2024/05/21 01:47
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2876
Ellipse, again and again
Time 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 is . We denote the focuses by F1 and F2. There is a point P in the plane. Draw a segment to associate the origin and P, which intersect the ellipse at point Q. Then draw a tangent of the ellipse which passes Q. Denote the distance from the center of the ellipse to the tangent by d. Calculate the value of .
Input
The first line contains a positive integer n that indicates number of test cases.
And each test case contains a line with four integers. The value of parameters of the ellipse a, b(0<|a|,|b|<=100),and the coordinates x, y of P(|x|<=100,|y|<=100) are given successively.
And each test case contains a line with four integers. The value of parameters of the ellipse a, b(0<|a|,|b|<=100),and the coordinates x, y of P(|x|<=100,|y|<=100) are given successively.
Output
For each test case, output one line. If the given point P lies inside the given ellipse, print "In ellipse" otherwise print the value of d*d*QF1*QF2 rounded to the nearest integer.
Sample Input
11 1 1 1
Sample Output
1
Source
2009 Multi-University Training Contest 8 - Host by BJNU
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);//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKxQ=sqrt((a*a*b*b*1.0)/(a*a*k1*k1+b*b));//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKyQ=k1*xQ;int flag= 0;//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKint w=a*a-b*b;//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKif((x0*x0)/(a*a)+(y0*y0)/(b*b)<1)//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK{printf("In ellipse\n");//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKcontinue;}if(w < 0)//标记焦点所在轴{flag =1;w=-w;}double F1,F2;//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKdouble c =sqrt(w*1.0);//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKif(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));//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKF2 = 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);//FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKdouble 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");elseprintf("%d\n",a*a*b*b);}}return 0;}
3 0
- HDU 2876 Ellipse, again and again(数学题)
- Hdu 2876 Ellipse, again and again
- HDU 2876 Ellipse, again and again(几何求解)
- TOJ 3363.Ellipse, again and again
- Fibonacci again and again HDU
- HDU 1848 - Fibonacci again and again(SG)
- hdu 1848 Fibonacci again and again(组合博弈)
- HDU 1848 Fibonacci again and again(博弈 SG运用)
- HDU 1848(sg博弈) Fibonacci again and again
- HDU 1848 Fibonacci again and again(SG函数)
- HDU 1848 Fibonacci again and again(博弈_SG函数)
- HDU-1848 Fibonacci again and again(组合游戏)
- hdu 1848 Fibonacci again and again (FIB博弈)
- HDU 1848Fibonacci again and again(博弈论:sg函数)
- [HDU 1848]Fibonacci again and again(博弈论)
- hdu 1848 Fibonacci again and again (博弈)
- HDU 1848 Fibonacci again and again (SG函数 模板)
- hdu 1848 Fibonacci again and again(nim博弈)
- CCRender使用
- 读取EXCEL文件并查询
- 一个Django的小例子(静态路径、url配置、ajax数据传递)
- Java For-each 的实现原理
- 转载]指示电量不足的简单电路设计
- HDU 2876 Ellipse, again and again(数学题)
- 使用supervisor提高nodejs调试效率
- 九度 1104 以及 辗转相除法的原理f昂发
- STL算法学习
- mysql 压力测试脚本
- 云享 文档协同,开启新的文档协作模式
- 下压栈(LIFO) (能动态调整数组大小的实现)
- stl容器学习总结
- POX学习笔记:事件系统分析