#include using namespace std; #define rep(i,n) for(int i=0;i vi; typedef vector > vvi; typedef pair pii; class Point{ public: Real x, y; Point() : x(0), y(0) {} Point(Real _x, Real _y) : x(_x), y(_y) {} Point(const Point &p) : x(p.x), y(p.y) {} Point operator+ (const Point &p) const{return Point(x + p.x, y + p.y);} Point operator- (const Point &p) const{return Point(x - p.x, y - p.y);} Point operator* (Real r) const{return Point(x * r, y * r); } bool operator< (const Point &p) const{return x != p.x ? x < p.x : y < p.y;} bool operator== (const Point &p) const{return x == p.x && y == p.y;} Real norm() const{return x * x + y * y; } Real abs() const{return sqrt(norm()); } Real dot(const Point &p) const{return x * p.x + y * p.y;} Real cross(const Point &p) const{return x * p.y - y * p.x;} }; typedef Point Vector; class Segment{ public: Point p1, p2; Segment() : p1(), p2(){} Segment(const Point &_p1, const Point &_p2) : p1(_p1), p2(_p2) {} Segment(const Segment &s) : p1(s.p1), p2(s.p2) {} }; typedef Segment Line; Point project(const Segment &s, const Point &p){ Vector base = s.p2 - s.p1; Real r = (p-s.p1).dot(base) / base.norm(); return s.p1 + base * r; } Point reflect(const Segment &s, const Point &p){ return p + (project(s, p) - p) * 2.0; } Point getCrossPoint(const Segment &s1, const Segment &s2) { Vector base = s2.p2 - s2.p1; Real d1 = abs(base.cross(s1.p1 - s2.p1)); Real d2 = abs(base.cross(s1.p2 - s2.p1)); Real t = d1 / (d1 + d2); return s1.p1 + (s1.p2 - s1.p1) * t; } const vi dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1}; template ostream& operator<< (ostream& out, const pair& p) { out << '(' << p.first << ", " << p.second << ')'; return out; } template ostream& operator<< (ostream& out, const vector& v) { out << '['; rep(i, v.size()) out << v[i] << ","; out << "\b], " << v.size(); return out; } void solve(){ Real ax,ay,bx,by; cin >> ax >> ay >> bx >> by; Point a(ax, ay), b(bx, by); cout << getCrossPoint(Segment(a,b), Segment(Point(), Point(0.0, 1024.0))).y << endl; } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(9); solve(); return 0; }