This one is also a shitty problem, had to try and error to get accepted, do not know why it got AC.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#include <iostream> #include <cmath> #include <cstdio> const double eps = 1e-6; using namespace std; int main() { int t,kase=1; double d,v,u; double x; cin>>t; while(t--) { cin>>d>>v>>u; printf("Case %d: ", kase++); if(u-v<eps || u<eps || v<eps) { printf("can't determine\n"); } else { x=sqrt(u*u-v*v); printf("%.3lf\n", d/x - d/u); } } return 0; } |