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公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...
随机推荐
- Linq语句与aspnetpager结合分页
public void DataBindList() { List<EnDeContent> listCon = null; in ...
- python多线程 批量下补丁
一个一个下载 要2个多小时.就直接起了个线程池.效果明显.import urllib2 from urlparse import urlparse uri = 'http://******/patch ...
- python中xrange()和range()函数的区别使用:
1.range()函数: 函数说明:range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列. >>> #ra ...
- ACMer程序员智力拾遗
浏览网页偶得,遂记录下来,每天进步一点点-- 博客园真是个不错的平台,今天我让师姐也注册了-- 学会分享吧,孩子们-- 一.编程中无穷大量的设置 ...
- jsp EL表达式 字符串的比较
jsp EL表达式 字符串的比较 跟JavaScript一样,直接使用两个等于号即可:== 代码如下: <c:if test="${highLight == 'visa'}" ...
- Eclipse下设置github开发环境
1.按照github上的指南配置(http://help.github.com/win-set-up-git/)基础的git环境. 2.在github上创建一个Repository. 3.在Eclip ...
- Android开源项目发现---ImageView 篇(持续更新)
1. PhotoView 支持双击或双指缩放的ImageView 在ViewPager等Scrolling view中正常使用,相比上面的AndroidTouchGallery,不仅支持ViewPag ...
- git支持中文
以前使用git,都要参考这个来进行中文支持 http://blog.csdn.net/son_of_god/article/details/7341928 有一次更新了git之后,发现默认支持了中文[ ...
- 《Spark大数据处理:技术、应用与性能优化 》
基本信息 作者: 高彦杰 丛书名:大数据技术丛书 出版社:机械工业出版社 ISBN:9787111483861 上架时间:2014-11-5 出版日期:2014 年11月 开本:16开 页码:255 ...
- ES2015 (ES6)
是时候使用ES 2015了 你可能不再需要Underscore BABEL Grunt 先 babel 再用 babel 后的文件 uglify 去掉严格模式.严格模式下全局的this转成了undef ...