#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 int sum = 0; int count = 0; int temp; for(int i = 0; i < m; i++) { if( i == 0 && sum <= s){ sum += p; count++; } if(i < m && temp != m && sum <= s){ sum = sum + p - d; temp = temp - d ; count++; } if (temp == m && sum <= s){ sum = sum + m; count++; } } return (count+1); } 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; }