#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 //p=cost of game, d=reducing factor ,m=base cost after which not reducing ,s= money in wallet 20 3 6 80 if(s==0) return 0; int flag=0; d=0; while(s>=m) { p-=d; flag++; s-=p; d=3; } return flag; } 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; }