HDU 2876 Ellipse, again and again
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2876
Ellipse, again and againTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Problem Description
There is an ellipse in the plane, its formula is
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
Sample Output
Source
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的更多相关文章
- hdu 1724 Ellipse simpson积分
/* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...
- HDU 1724 Ellipse 【自适应Simpson积分】
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU 1724 Ellipse (自适应辛普森积分)
题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...
- HDU 1724 Ellipse(数值积分の辛普森公式)
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...
- HDU 1724 Ellipse [辛普森积分]
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU 1724 Ellipse
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...
- hdu 1724 Ellipse——辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...
- hdu 1724 Ellipse —— 自适应辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 函数都给出来了,可以用辛普森积分: 一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 ...
- HDU 1724 Ellipse 自适应simpson积分
simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...
随机推荐
- Mongoengine 使用笔记
1.直接将某个document对象导出对应的json数据. #models class Feed(Document): """ @summary: 所有订阅内容 &quo ...
- We7在政府门户中的应用
政府门户从传统的信息引导发展到现阶段的服务型门户,不论从角度转变上还是从平台选型上都跟以前有很大的不同,其更注重的是安全.扩展.易用和移动互联网几部分(当然这儿的注重是建立在已有政府门户电子政务三个板 ...
- warning: no newline at end of file
编译错误:warning: no newline at end of file原因:程序结尾需要有一个空行解决办法:在程序末尾多打个回车就行了
- ARM编译器4字节对齐
(1)我们假设只有一个赋初值的char型全局变量,那么系统会在data区分配一个4字节的存储空间来存储它.实际上,只用了1个字节,但是为了4字节对齐,只好分配4个字节,所以就会有3个字节浪费. (2) ...
- aspose.cells根据模板导出excel
又隔十多天没写博客了,最近都在忙项目的事情,公司人事变动也比较大,手头上就又多了一个项目.最近做用aspose.cells根据模板导出excel报价单的功能,顺便把相关的核心记下来,先上模板和导出的效 ...
- 【转】成为Java顶尖程序员 ,看这11本书就够了
成为Java顶尖程序员 ,看这11本书就够了 转自:http://developer.51cto.com/art/201512/503095.htm 以下是我推荐给Java开发者们的一些值得一看的好书 ...
- mvc4 membership, [Win32Exception (0x80004005): The system cannot find the file specified]
public class UsersContext : DbContext { public UsersContext() : base("conn1") //change the ...
- NET Core 整合Autofac和Castle
NET Core 整合Autofac和Castle 阅读目录 前言: 1.ASP.NET Core中的Autofac 2.整合Castle的DynamicProxy 3.注意事项 回到目录 前言: 除 ...
- poj 1132
暑假集训做的第一个题,模拟,挺简单的,不过要细心点... 没什么好说的,直接贴代码: #include<cstdio> #include<cstring> using name ...
- AFN演示