题目链接:http://acm.tju.edu.cn/toj/showp3363.html
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 142 Accepted Runs: 65
There is an ellipse in the plane, its formula is
x2 / a2 + y2 / b2 = 1. 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
d2|QF1||QF2|.
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.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*QF 1*QF 2 rounded to the nearest integer.Sample Input
1 1 1 1 1
Sample Output
1
Source: Multi-School Training Contest #8 [Hosted By BNU]
椭圆原点到圆上切线的距离d有公式,总之d^2*|F1||F2| = a*a*b*b.
#include <stdio.h>
#include <algorithm>
int main(){
int a,b,x,y,n;
scanf("%d",&n);
while(n--){
scanf("%d%d%d%d",&a,&b,&x,&y);
if ((x*x)/(a*a) + (y*y)/(b*b) < 1)
printf("In ellipse\n");
else
printf("%d\n", a*a*b*b);
}
return 0;
}