#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 a[10000],temp,count=0,v,sum,c; a[0]=p; sum=p; for(int i=1;sum<=s;i++) { temp=p-d; if(temp>m) { a[i]=temp; sum=sum+a[i]; count++; } v=sum; c=count; if(temp<=m) { if(v<=s) { v=v+m; } } } 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+2); return 0; }