Cod sursă (job #470628)

Utilizator avatar ctrohin Cristina Trohin ctrohin IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,51 kb
Rundă Arhiva de probleme Status evaluat
Dată 14 apr. 2019 19:26:37 Scor 100
#include <bits/stdc++.h>
using namespace std;

int i,j,c,m,x,t,k;
int b,a;

int main()
{
    ifstream cin("scv.in");
    ofstream cout("scv.out");
    cin >> c >> t >> m >> x;
    k=m;
    while (a<x)
    {
        while (a<min(x,c)){
		        ++b;
				a=a+m;}
        if (a+m*t+m*(c/k)<x)
        {
            a=a+(m*t-c);
            b=t+b;
            m=m+k;
        }else
        {
            if ((x-a)%m!=0) b++;
            b=b+(x-a)/m; a=x;
        }
    }
	cout << b;
    return 0;
}