SHARE
TWEET

Untitled

a guest Jun 20th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.     freopen("mosalah.in", "r", stdin);
  6.     long long a, N , M , X , Y;
  7.     cin >> a;
  8.     for (int i = 0; i < a; i++) {
  9.         cin >> N >> M >> X >> Y;
  10.         if (Y == 0 && M < N * (X+Y))
  11.             cout << -1 << endl;
  12.         else if (N * (X+Y) < M)
  13.             cout << 0 << endl;
  14.         else
  15.             cout << N * (X+Y) - M << endl;
  16.     }
  17.    
  18.     return 0;
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top