#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 cost=p; int count=1; int prev=p; while(cost<=s){ if((prev-d) >= m){ //printf("prev\n"); cost=cost+(prev-d); prev=prev-d; count++; } else{ // printf("nprev\n"); cost=cost+m; count++; } } if(cost>s) return count-1; else return count; } 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; }