#include #include #include #include #include using namespace std; int main() { int d; cin >> d; int h1, h2, h3; cin >> h1 >> h2 >> h3; if(d == 0) { if(h1 != h2 && h1 != h3 && h2 != h3) { if(h1 < h2 && h3 < h2) { cout << 0; return 0; } if(h1 > h2 && h3 > h2) { cout << 0; return 0; } } cout << -1; return 0; } if(h1 != h2 && h1 != h3 && h2 != h3) { if(h1 < h2 && h3 < h2) { cout << 0; return 0; } if(h1 > h2 && h3 > h2) { cout << 0; return 0; } if(h1 > h2 && h1 > h3) // h2 > h3 { int temp = h1; h1 = h3; h3 = temp; } // h1 < h2 < h3 int mh3 = (h3 - h2) / d + 1; if(h3 - mh3*d == h1) mh3++; int mh2 = (h2 - h1) / d + 1; if(h2 - mh2*d >= 0 && h3 - mh3*d >= 0) { cout << min(mh2, mh3); } else if(h2 - mh2*d >= 0) { cout << mh2; } else if( h3 - mh3*d >= 0) { cout << mh3; } else { cout << -1; } return 0; } if(h1 == h2 == h3) { if(h1 - d*2 >= 0) { cout << 3; } else { cout << -1; } return 0; } if(h1 == h3) { if(h1 < d) { cout << -1; } else { if(h2 > h1) { cout << 1; } else if(h3-d > h2) { cout << 1; } else if(h2 > d) { cout << 2; } else { cout << -1; } } return 0; } if(h1 == h2) { h1 = h3; h3 = h2; } // h1 != h2 == h3 if(h1 < h2) { if(h3 < d) { cout << -1; } else { int a = 1; if(h3 - d == h1) a++; if(h3 - a*d >= 0) { cout << a; } else { cout << -1; } } return 0; } else { if(h2 >= d) { cout << 1; } else { cout << -1; } return 0; } cout << -1; return 0; }