|
|
back to boardI am sure that my algo is right,but WA#4 Posted by nargiT 30 Jul 2010 20:19 // 1075.cpp : Defines the entry point for the console application. // #include <iostream> #include <cmath> #include <algorithm> #include <iomanip> #include <stdio.h> using namespace std; struct point{ int x; int y; int z; void in(point *); double dist(point *,point *); }Tigran; void point::in(point *a){ cin>>a->x; cin>>a->y; cin>>a->z; } double point::dist(point *a, point *b){ double res_x,res_y,res_z; double total_res; res_x=((a->x)-(b->x))*((a->x)-(b->x)); res_y=((a->y)-(b->y))*((a->y)-(b->y)); res_z=((a->z)-(b->z))*((a->z)-(b->z)); total_res=sqrt(res_x+res_y+res_z); return (total_res); } int main(){ double answer; point a,b,c; double t; double d; double x,y,z; int R; Tigran.in(&a); Tigran.in(&b); Tigran.in(&c); cin>>R; x=Tigran.dist(&a,&c); y=Tigran.dist(&b,&c); z=Tigran.dist(&a,&b); if((x*x+z*z<=y*y) && (y*y+z*z<=x*x)){ answer=z; } else { t=acos((x*x+y*y-z*z)/(2*x*y)); d=(x*y*sin(t))/z; if(d>=(double)R){ answer=z; } else { answer=sqrt(x*x-R*R)+sqrt(y*y-R*R)+R*(t-acos(R/x)-acos(R/y)); } } printf("%0.2f",answer); return (0); } |
|
|