zoj 1439 Area Ratio

/* 数学题 套公式就行 */ #define LOCAL #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<cstdlib> #include<iomanip> #include<string> #include<algorithm> #include<ctime> #include<stack> #include<queue> #include<vector> #define N 10005 using namespace std; double getedge(double x1,double y1,double z1,double x2,double y2,double z2) {return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));} int main() { #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif double x1,y1,z1,x2,y2,z2,x3,y3,z3,a,b,c,r,R,p,s; while(cin>>x1>>y1>>z1>>x2>>y2>>z2>>x3>>y3>>z3) { a=getedge(x1,y1,z1,x2,y2,z2); b=getedge(x1,y1,z1,x3,y3,z3); c=getedge(x2,y2,z2,x3,y3,z3); p=(a+b+c)/2.0; s=sqrt(p*(p-a)*(p-b)*(p-c)); r=s/p; R=a*b*c/(4*s); cout<<setprecision(3)<<setiosflags(ios::fixed)<<r*r/(R*R)<<endl; } return 0; }#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<cstdlib> #include<iomanip> #include<string> #include<algorithm> #include<ctime> #include<stack> #include<queue> #include<vector> #define N 10005 using namespace std; double getedge(double x1,double y1,double z1,double x2,double y2,double z2) {return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));} double getsinc(double a,double b,double c) {double ans=(a*a+b*b-c*c)/(2*a*b);return sqrt(1-ans*ans);} int main() { #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif double x1,y1,z1,x2,y2,z2,x3,y3,z3,a,b,c,r,R,p,s,sinc; while(cin>>x1>>y1>>z1>>x2>>y2>>z2>>x3>>y3>>z3) { a=getedge(x1,y1,z1,x2,y2,z2); b=getedge(x1,y1,z1,x3,y3,z3); c=getedge(x2,y2,z2,x3,y3,z3); p=(a+b+c)/2.0; s=sqrt(p*(p-a)*(p-b)*(p-c)); r=s/p; sinc=getsinc(a,b,c); R=c/(2*sinc); cout<<setprecision(3)<<setiosflags(ios::fixed)<<r*r/(R*R)<<endl; } return 0; }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值