#include #include #include #include #include #include #include int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy if(s < m) return 0; int ctr =0; int s1 = s; if(s>=p){ s = s-p; ctr++;} else return 0; int c = p-d; while(c > m && s>= c){ s = s-c; c = c-d; ctr++; } while(s >= m && c <= m){ s = s-m; ctr++; } return ctr; } int main() { int p; int d; int m; int s; scanf("%i %i %i %i", &p, &d, &m, &s); int answer = howManyGames(p, d, m, s); printf("%d\n", answer); return 0; }