aboutsummaryrefslogtreecommitdiff
path: root/codechef/chefAndHisApps/main.cpp
blob: 8d38e22720df4d9ac320b1be8c62ea8595d68832 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tt;
  cin >> tt;
  while (tt--) {
    int s, x, y, z;
    cin >> s >> x >> y >> z;
    int xy = x + y;
    int free = s - xy;
    int count = 0;
    int mx = max(x, y);
    // 3 <= 7
    if (z <= free) {
      cout << 0 << endl;
    } else {
      while (z > free) {
        z -= max(x, y);
        if (x > y) {
          x = 0;
        } else {
          y = 0;
        }
        count++;
      }
      cout << count << endl;
    }
  }
}