HDU 2876 Ellipse, again and again(几何求解)

7 篇文章 0 订阅

原题: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): 560    Accepted Submission(s): 209


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.
 

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
  
  
1 1 1 1 1
 

Sample Output
  
  
1
解题思路:(摄像头坏了,请谅解~~)


AC代码:

#include <stdio.h>
/*
author:Yangsir
time:2014/5/10
*/
int main()
{
	int n;
	double a,b,x,y,m;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
		m=a*a*b*b;
		if(x*x/a/a+y*y/b/b<1)
			printf("In ellipse\n");
		else
			printf("%.0lf\n",m);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值