TOJ 3363.Ellipse, again and again

9 篇文章 0 订阅
4 篇文章 0 订阅

题目链接:http://acm.tju.edu.cn/toj/showp3363.html


3363.    Ellipse, again and again
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]
Submit   List    Runs   Forum   Statistics


椭圆原点到圆上切线的距离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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值