#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include//assert(); //#include //xAOJ ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; typedef unsigned long long ULL; ///////// using namespace::std; ///////// ///////// vector H(3); bool check(){ if( H[0] == H[1] || H[1] == H[2] || H[2] == H[0] ){ return false; }else if( H[0] < H[1] && H[2] < H[1] ){ return true; }else if( H[0] > H[1] && H[2] > H[1] ){ return true; } return false; } LL cut(LL A,LL B,LL C,LL d){ //A>B>C LL ret = 0; LL temp; if( A <= B ){ temp = (B-A+d)/d; B = B - d*temp; if( B < 0 ){ B = 0; } if( A > B && B > 0){ ret += temp; }else{ return -1; } } /////////////// if( B <= C ){ temp = (C-B+d)/d; C = C - d*temp; if( C < 0 ){ C = 0; } if( B > C && C >= 0){ ret += temp; }else{ return -1; } } return ret; } void solve(){ LL d; cin >> d;// rep(i,3){ cin >> H[i]; } if( 0 == d ){ if( check() ){ cout << 0 << endl; }else{ cout << -1 << endl; } return; } //else if(H[0] >= 3*d && H[1]>= 3*d && H[2] >= 3*d){} //// LL ret = -1; LL temp; //LL cut(int A,int B,int C,int d) //(1,0,2)(1,2,0)(0,2,1)(2,0,1) temp = cut(H[1],H[0],H[2],d); if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}} temp = cut(H[1],H[2],H[0],d); if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}} temp = cut(H[0],H[2],H[1],d); if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}} temp = cut(H[2],H[0],H[1],d); if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}} cout << ret << endl; } int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(16);// //cpp solve(); return 0; }