HDU 2876 Ellipse, again and again

转载请注明出处: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 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.

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

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);//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

时间: 2024-10-12 03:07:40

HDU 2876 Ellipse, again and again的相关文章

HDU 1724 Ellipse 【自适应Simpson积分】

Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1977    Accepted Submission(s): 832 Problem Description Math is important!! Many students failed in 2+2's mathematical test, so let's AC t

HDU 1724 Ellipse [辛普森积分]

Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1868    Accepted Submission(s): 792 Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC t

HDU - 1724 Ellipse(simpson积分)(入门模板题)

原题链接 题意: 给定 a,b,l,r,求 与x = l,x = r 围成的封闭图形的面积. 思路: 大佬可以直接算一下原函数就出来了,当没法计算或者很难计算的时候就可以用 自适应simpson 积分来逼近真实值. 1 /* 2 * @Author: windystreet 3 * @Date: 2018-08-04 16:24:01 4 * @Last Modified by: windystreet 5 * @Last Modified time: 2018-08-04 16:24:33 6

多校 2009 7

中间那几场    不太会 B  HDU 2873 n *m矩阵  #表示有炸弹 选这个炸弹后可以在  他上面  左边  任意位子 产生一一个炸弹  丢到1,1的自动爆炸 最后没的弄就输掉 sg函数     第一行第一列处理下 #include<stdio.h> #include<string.h> #include<algorithm> #include<queue> #include<math.h> using namespace std; #

【HDU 1724】Ellipse

Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1358    Accepted Submission(s): 532 Problem Description Math is important!! Many students failed in 2+2's mathematical test, so let's AC

[HDU1724]Ellipse

题目:Ellipse 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1724 题目简述:给定一个椭圆,求椭圆上一个区间[l,r]的面积. 分析: (1)椭圆方程式:$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$. (2)椭圆上[l,r]区间的面积由X轴上方与X轴下方2部分组成,由于两部分面积一样,我们只考虑X轴上方的那部分面积. (3)椭圆上y关于x的变化函数:$y=f(x)=\frac{b}{a}*\sqrt{a^2-x^2

hdu 1714 RedField

RedField Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 639    Accepted Submission(s): 213 Problem Description As the graph you see below, we named the red part "RedField".The read part i

HDU 6203 ping ping ping [LCA,贪心,DFS序,BIT(树状数组)]

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6203] 题意 :给出一棵树,如果(a,b)路径上有坏点,那么(a,b)之间不联通,给出一些不联通的点对,然后判断最少有多少个坏点. 题解 :求每个点对的LCA,然后根据LCA的深度排序.从LCA最深的点对开始,如果a或者b点已经有点被标记了,那么continue,否者标记(a,b)LCA的子树每个顶点加1. #include<Bits/stdc++.h> using namespace std;

HDU 5542 The Battle of Chibi dp+树状数组

题目:http://acm.hdu.edu.cn/showproblem.php?pid=5542 题意:给你n个数,求其中上升子序列长度为m的个数 可以考虑用dp[i][j]表示以a[i]结尾的长度为j的上升子序列有多少 裸的dp是o(n2m) 所以需要优化 我们可以发现dp的第3维是找比它小的数,那么就可以用树状数组来找 这样就可以降低复杂度 #include<iostream> #include<cstdio> #include<cstring> #include