为防止广告,目前nocow只有登录用户能够创建新页面。如要创建页面请先登录/注册(新用户需要等待1个小时才能正常使用该功能)。
URAL/1294
来自NOCOW
< URAL
数学题。。。
#include <iostream> #include <cmath> using namespace std; const double zero=1e-6; double a,b,c,d,x; int main() { cin >> a >> b >> c >> d; if (fabs(a*b-c*d) < zero) { cout << "Impossible." << endl; return 0; } a*=1000.0,b*=1000.0,c*=1000.0,d*=1000.0; x=(a*b*(c*c+d*d)-c*d*(a*a+b*b))/(a*b-c*d); if (x < -zero) cout << "Impossible." << endl; else { cout.precision(0); cout.setf(ios::fixed); cout << "Distance is " << sqrt(x+zero) << " km." << endl; } return 0; } //by zzy
/*gaoshangbo*/ #include <iostream> #include <math.h> using namespace std; #define ep 1e-8 int main() { double a, b, c, d, ans; scanf("%lf%lf%lf%lf", &a, &b, &c, &d); a *= 1000.0; b *= 1000.0; c*= 1000.0; d *= 1000.0; if(fabs(c*d - a*b) < ep) printf("Impossible.\n"); else { ans = sqrt((c*d*(a*a+b*b)-a*b*(c*c+d*d))/(c*d-a*b)); printf("Distance is %.0lf km.\n", ans); } }