LJOJ 1576 Easy Problem
来源:互联网 发布:制作朋友圈的软件 编辑:程序博客网 时间:2024/06/08 08:24
题意就是http://blog.csdn.net/kaisa158/article/details/47023997
刚开始把判两个点几乎重合的那个-写了sigma{sqr(每个点)}被卡精度,改成abs就a了
//By Richard#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <cstdlib>#include <cmath>#include <ctime>#define rep(x,y,z) for (int x=(y);(x)<=(z);(x)++)#define per(x,y,z) for (int x=(y);(x)>=(z);(x)--)#define log2(x) (31-__builtin_clz(x))#define mod (int)(1e9+7)#define inf 0x3f3f3f3f#define cls(x) memset(x,0,sizeof(x))#ifdef DEBUG#define debugdo(X) X#define debugndo(X)#define debugout(X) cout<<(#X)<<"="<<(X)<<endl#else#define debugdo(X)#define debugndo(X) X#define debugout(X)#endif // debug#ifdef ONLINE_JUDGE#define debugdo(X)#define debugndo(X)#define debugout(X)#endif#define putarray(x,n) rep(iiii,1,n) printf("%d ",x[iiii])#define mp make_pairusing namespace std;typedef pair<int,int> pairs;typedef long long LL;/////////////////////read3.0////////////////////////////////////template <typename T>inline void read(T &x){char ch;x=0;bool flag=false;ch=getchar();while (ch>'9'||ch<'0') {ch=getchar();if (ch=='-') flag=true;}while ((ch<='9'&&ch>='0')){x=x*10+ch-'0';ch=getchar();}if (flag) x*=-1;}template <typename T>inline void read(T &x,T &y){read(x);read(y);}/////////////////variables&functions////////////////////typedef long double LD;int T;#define sqr(x) ((x)*(x))struct point{LD x,y,z;point(LD a=0,LD b=0,LD c=0):x(a),y(b),z(c){}inline bool operator<(point b)const{return x==b.x?y<b.y:x<b.x;}inline LD operator-(point b)const{return abs(x-b.x)+abs(y-b.y)+abs(z-b.z);}};double xp,yp,zp,x,y,z,xx,yy,zz;const LD eps=0.000000000001;LD dis(const point &x,const point &y){return sqrt(sqr(x.x-y.x)+sqr(x.y-y.y)+sqr(x.z-y.z));}int main(){read(T);rep(iii,1,T){scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf",&xp,&yp,&zp,&x,&y,&z,&xx,&yy,&zz);point pp(xp,yp,zp);point l(x,y,z),r(xx,yy,zz);if (r<l) swap(l,r);while (r-l>eps){point ll((r.x-l.x)/3+l.x,(r.y-l.y)/3+l.y,(r.z-l.z)/3+l.z),rr((r.x-l.x)*2/3+l.x,(r.y-l.y)*2/3+l.y,(r.z-l.z)*2/3+l.z);LD disll=dis(pp,ll),disrr=dis(pp,rr);if (disll<disrr) r=rr;else l=ll;}printf("Case %d: %.2lf\n",iii,(double)dis(pp,l));}return 0;}
阅读全文
0 0
- LJOJ 1576 Easy Problem
- easy problem
- SetType,a easy problem
- An Easy Problem
- 2055 An easy problem
- An Easy Problem!
- An Easy Problem!
- Easy Problem(cdOJ1644)
- 【模拟】Another Easy Problem
- FZU_1753 Another Easy Problem
- fzu1753 Another Easy Problem
- poj2826 An Easy Problem?!
- A problem is easy
- 三分法Easy Problem
- HDOJ2055 An easy problem
- 23:Easy problem
- An Easy Problem
- hdu2055An easy problem
- [LINUX] ps -ef和ps aux的区别及格式详解
- Keepliaved介绍
- 找规律+菊花图
- 什么是VB.NET-
- 35 个 Java 代码性能优化总结
- LJOJ 1576 Easy Problem
- Investment HDU
- 畅通工程 HDU
- 01背包
- 重签名提示:无法对jar进行签名,java.util.zip.ZipException: invalid entry compressed size
- HDU6098-Inversion
- 周末torch7闪电战(blitz)
- android toolbar menu navigationIcon
- Hibernate实例--注解配置表映射