#include #include #include #include #include #include #include int max(int a, int b){ return(a>b)?a:b; } int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy int p_c = p,num_games_bought = 0; while(s >= p_c){ s -= p_c; p_c = max(p_c - d, m); num_games_bought++; } return num_games_bought; } 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; }